当前位置:网站首页>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 .
边栏推荐
- WPF format datetime in TextBlock- WPF format DateTime in TextBlock?
- Chapter 1: find the factorial n of n!
- 03 -- QT OpenGL EBO draw triangle
- 04 -- QT OpenGL two sets of shaders draw two triangles
- 5- (4-nitrophenyl) - 10,15,20-triphenylporphyrin ntpph2/ntppzn/ntppmn/ntppfe/ntppni/ntppcu/ntppcd/ntppco and other metal complexes
- Today's work summary and plan: February 14, 2022
- What is the difference between a kill process and a close process- What are the differences between kill process and close process?
- Day10 -- forced login, token refresh and JWT disable
- 05 -- QT OpenGL draw cube uniform
- Summary of 90 day learning materials and notes of Zhang Fei's actual electronic hardware engineer
猜你喜欢

2022 Xinjiang latest road transportation safety officer simulation examination questions and answers

2022-06-27 advanced network engineering (XII) IS-IS overhead type, overhead calculation, LSP processing mechanism, route revocation, route penetration

Chapter 1: find all factorial sums, Grand Prix site unified programming, three factorial sums, graphic point scanning, recursive factorial n of n!, Find the factorial n of n!, King Shehan miscalculate

BOC protected tryptophan porphyrin compound (TAPP Trp BOC) Pink Solid 162.8mg supply - Qiyue supply
![[Yu Yue education] basic reference materials of manufacturing technology of Shanghai Jiaotong University](/img/95/5baf5c8bedb00e67394a6c0a8234ff.png)
[Yu Yue education] basic reference materials of manufacturing technology of Shanghai Jiaotong University

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

Network security Kali penetration learning how to get started with web penetration how to scan based on nmap

I study database at station B (4): DQL

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

kubernetes集群搭建efk日志收集平台
随机推荐
NFT without IPFs and completely on the chain?
PR 2021 quick start tutorial, how to create new projects and basic settings of preferences?
Typora charges, WTF? Still need support
The simplicity of laravel
FPGA learning notes: vivado 2019.1 project creation
Basic principle of LSM tree
3. Data binding
IP address is such an important knowledge that it's useless to listen to a younger student?
Realize user registration and login
Nacos usage of micro services
Day11 - my page, user information acquisition, modification and channel interface
Day11 ---- 我的页面, 用户信息获取修改与频道接口
PR notes:
Chapter 1: seek common? Decimal and S (D, n)
What is the content of game modeling
Win10 share you don't have permission
Don't be afraid of no foundation. Zero foundation doesn't need any technology to reinstall the computer system
Chapter 1: sum of three factorials, graph point scanning
2022-06-30 advanced network engineering (XIV) routing strategy - matching tools [ACL, IP prefix list], policy tools [filter policy]
Chapter 1: drinking soft drinks, step tariff calculation, step tariff calculation function, personal income tax, solving square root inequality, simplifying solving square root inequality, solving dem