当前位置:网站首页>44. Concurrent programming theory
44. Concurrent programming theory
2022-07-03 19:50:00 【Python_ twenty-one】
List of articles
1. Procedures and processes
A program is a code file , Process refers to the running process of a program .
The same program is executed many times , It's multiple processes .
process :CUP The process of executing a program .
There are many tasks to be performed at the same time , however cpu There can only be one thing at a time .
2. The program runs in three states

When the program is created and executed , The first thing to enter is the ready state , Wait for the operating system scheduling to start running .
Encountered in execution I/O The event request of the operation will enter the blocking state , Wait for the result .
After getting the return, instead of running immediately, it enters the ready state and waits for the operating system to call ready to run again .
3. Concurrency and parallelism
Concurrent : It's pseudo parallelism , It feels like it's running at the same time , Single cpu+ Implementation of multi-channel technology , Parallel also belongs to concurrent .
Multi channel technology can realize cpu Division of time slice of each program process , Each program is executed for a period of time , Switch between different programs , Too fast , It makes people feel that they are running at the same time .
parallel : Really run at the same time , need cpu With multi-core .
A kernel performs a task . When there are more tasks than the kernel , Only when the first few tasks are executed I/O Interrupt execution , Will be assigned to other tasks for temporary execution ,I/O The end operating system will call it again .
Today's computers run multiple tasks at the same time , A task can be understood as a process .

The concurrent implementation of a process is that the hardware interrupts a running process , Save all the states in the program at this time , The operating system will record in a process table ( Each process occupies a process representation , These entries are also called process control modules ) Ensure that the program starts again as if it had never been interrupted .
4. Synchronous asynchronous
Synchronous and asynchronous : Describes how the task is submitted .
Sync : After the task is submitted , Wait in place for the return result of the task , Don't do anything while waiting .
asynchronous : After the task is submitted , Don't wait for the returned result , To do something else , The return result of the task will be automatically processed by an asynchronous callback mechanism .
5. Blocking non blocking
Blocking non blocking : Describe the running state of the program .
Blocking : Before the call result returns , The current thread will be suspended , Only after the result is obtained will it return ( Blocking state ).
Non blocking : Before you can't get the results immediately , Go straight back to .( The ready state , Running state ).
ps:
Combination of appeal concepts : The most efficient combination : Asynchronous non-blocking .
Ideal state : The code written is always switched between ready state and running state , Difficult to achieve .
6. Process creation
Hardware requires operating system management , As long as there is an operating system, there is the concept of process .
New processes are created by an existing process .
Subprocesses : A process created by a process .
The parent process : The process that created the new process .
windows The lower parent process creates child processes with different address spaces ,( Multichannel technology requires the physical layer to realize the memory isolation between processes ), Any modification of a process in its address space will not affect another process .
7. Zombies and orphans
Zombie process : When you start a child process , The occupied process number will not be released immediately after the process ends .
The parent process needs to be able to view the basic information of its child processes , The amount of pid No. running time, etc .
All processes will enter the zombie process , Wait for the parent process to view .
The parent process does not die and creates child processes infinitely , And the subprocess will not end .
Orphan process : Child processes survive , The parent process died unexpectedly , The operating system will start a management program , Manage orphan processes and recycle related resources .
8. Termination of process
1. The normal exit ( Exit after the normal execution of the program , Or execute the end command of the program ).
2. Error exit ( The execution file does not exist )
3. Serious mistakes ( Execution of illegal orders , Reference does not exist , Be able to catch exceptions ).
4. Forced to end by other processes .
9. Process scheduling
Process scheduling : Long and short assignments are cpu The division of .
First come first serve scheduling algorithm : Good for long work , It's useless to work too often ,
Short job first algorithm : It's good for short work , Long homework is useless .
Time slice rotation + Multistage feedback queue :
Time slice : Divide the fixed time into N Multipoint , Each copy represents a time slice .
Set the multi-level ready queue , Queue priority at all levels from high to low , Time slice is divided from small to large .
The new process first enters the first level queue , Waiting in line to be allocated time slice .
If you run out of time , The process is not over , Then the process enters the end of the next level queue .
边栏推荐
- Zhang Fei hardware 90 day learning notes - personal records on day 2, please see my personal profile / homepage for the complete
- Promethus
- PR 2021 quick start tutorial, how to create new projects and basic settings of preferences?
- IPv6 experiment
- BOC protected tryptophan zinc porphyrin (Zn · TAPP Trp BOC) / copper porphyrin (Cu · TAPP Trp BOC) / cobalt porphyrin (cobalt · TAPP Trp BOC) / iron porphyrin (Fe · TAPP Trp BOC) / Qiyue supply
- 2022-06-30 網工進階(十四)路由策略-匹配工具【ACL、IP-Prefix List】、策略工具【Filter-Policy】
- Find a line in a file and remove it
- Rd file name conflict when extending a S4 method of some other package
- How to check the permission to write to a directory or file- How do you check for permissions to write to a directory or file?
- BOC protected alanine zinc porphyrin Zn · TAPP ala BOC / alanine zinc porphyrin Zn · TAPP ala BOC / alanine zinc porphyrin Zn · TAPP ala BOC / alanine zinc porphyrin Zn · TAPP ala BOC supplied by Qiyu
猜你喜欢

Explore the internal mechanism of modern browsers (I) (original translation)

Common text labels

Chapter 1: sum of three factorials, graph point scanning
![Chapter 2: find the number of daffodils based on decomposition, find the number of daffodils based on combination, find the conformal number in [x, y], explore the n-bit conformal number, recursively](/img/c5/0081689817700770f6210d50ec4e1f.png)
Chapter 2: find the number of daffodils based on decomposition, find the number of daffodils based on combination, find the conformal number in [x, y], explore the n-bit conformal number, recursively

Chapter 1: extend the same code decimal sum s (D, n)

第一章: 舍罕王失算

Detailed and not wordy. Share the win10 tutorial of computer reinstallation system

Chapter 2: find the classical solution of the maximum Convention and the least common multiple of a and B, find the conventional solution of the maximum Convention and the least common multiple of a a

Xctf attack and defense world crypto master advanced area olddriver

第二章:4位卡普雷卡数,搜索偶数位卡普雷卡数,搜索n位2段和平方数,m位不含0的巧妙平方数,指定数字组成没有重复数字的7位平方数,求指定区间内的勾股数组,求指定区间内的倒立勾股数组
随机推荐
Part 27 supplement (27) buttons of QML basic elements
Chapter 1: extend the same code decimal sum s (D, n)
Geek Daily: the system of monitoring employees' turnover intention has been deeply convinced off the shelves; The meta universe app of wechat and QQ was actively removed from the shelves; IntelliJ pla
Chapter 2: find the classical solution of the maximum Convention and the least common multiple of a and B, find the conventional solution of the maximum Convention and the least common multiple of a a
PR FAQ: how to set PR vertical screen sequence?
Chapter 20: y= sin (x) /x, rambling coordinate system calculation, y= sin (x) /x with profile graphics, Olympic rings, ball rolling and bouncing, water display, rectangular optimization cutting, R que
2022-06-27 网工进阶(十二)IS-IS-开销类型、开销计算、LSP的处理机制、路由撤销、路由渗透
Pecan — @expose()
第一章:求所有阶乘和数,大奖赛现场统分程序设计,三位阶乘和数,图形点扫描,递归求n的阶乘n!,求n的阶乘n!,舍罕王失算
[Yu Yue education] basic reference materials of manufacturing technology of Shanghai Jiaotong University
QT -- qfile file read / write operation
PR 2021 quick start tutorial, material import and management
Ae/pr/fcpx super visual effects plug-in package fxfactory
第二章:4位卡普雷卡数,搜索偶数位卡普雷卡数,搜索n位2段和平方数,m位不含0的巧妙平方数,指定数字组成没有重复数字的7位平方数,求指定区间内的勾股数组,求指定区间内的倒立勾股数组
Blue Bridge Cup: the fourth preliminary - "simulated intelligent irrigation system"
unittest框架基本使用
01 - QT OpenGL display OpenGL window
Chapter 1: find the algebraic sum of odd factors, find the same decimal sum s (D, n), simplify the same code decimal sum s (D, n), expand the same code decimal sum s (D, n)
Nacos usage of micro services
2022-07-02 advanced network engineering (XV) routing policy - route policy feature, policy based routing, MQC (modular QoS command line)