Chapter three process

1, The concept of process : Procedures in execution

2, The difference between process and program

A program is not a process , A program is just a passive entity , A process is an active entity , When an executable file is loaded into memory , Only a program can be called a process .

* Process is a dynamic concept , Program is a static concept ;
* A process has a life cycle , There are birth and death , Transient ; And the program is relatively long-term .
* Processes are concurrent , And the program didn't ;
* Process is the basic unit competing for computer system resources , Its concurrency is restricted by the system itself ;
* Different processes can contain the same program , As long as the data set corresponding to the program is different
3, Process state and its transformation |||||||

new : The process is being created

function : The instruction is being executed

wait for : The process waits for an event to occur

be ready : Process waiting to allocate processor

termination : Process complete execution

4, Process control block

Each process is represented by a program control block in the operating system (PCB): Include process status , Program counter ,CPU register ,CPU Dispatch information , Memory management information , Accounting information ,I/O status information

PCB It is used to save important information during program running , Unique identification of the existence of the process , Recorded OS All the information needed to describe and control a process , Process and PCB It's a one-to-one correspondence

5, Process scheduling : Select an available process to CPU Execution on

6, Job queue : Save all the processes in the system , When a process enters the system, it will be added to the job queue

7, Ready queue : Memory resident , Programs waiting to run are stored in the ready queue

8, Device queue : wait for I/O Process of the device , Each device has its own device queue

9, Scheduler : Process selection has corresponding scheduler execution

10, Long term scheduling ( job scheduling ): Select a process to enter the memory ready queue , Controlling the degree of multiprogramming ( Number of processes in memory ), Not often

11, Short term scheduling (CPU dispatch ): Select a process from the ready queue , And distribute it CPU

12, The difference between the two : Frequency of execution

13, Medium term scheduling : Intermediate scheduling mainly completes the virtual memory management related to the swap in and swap out operation

14, Context switch ( Scheduling process ): When CPU
When switching to another process , The system needs to save the state of the old process , And load the state of the new process , The time of context switching is an extra cost of the system , When switching, the system does not do any useful work , Time is closely related to hardware support

15, Process operation : Process creation , Process termination

Process creation : Parent process creates child process , The child process continues to create , So as to form a process tree

Process termination : The parent process can abort the execution of the child process

16, The reason why the parent process can abort the execution of the child process :

* The subprocess uses more resources than it is allocated to
* The task of the child process is no longer needed
* If the parent process ends , Some operating systems do not allow child processes to continue

17, Exchange technology , Switching technology : Process that cannot run in memory , Or temporarily unused data and programs , Swap out to external storage , To make enough memory space , Put the process that already has the running conditions into practice , Or data and programs needed by the process , Swap in memory

18, Process classification :I/O The main process ,CPU The main process

19, Process termination implementation

The first step : Based on the identifier of the terminated process , from PCB Set to find the corresponding process control block and read out the status of the process ;

Step two : If the terminated process is in execution state , The execution of the process is terminated , And set the dispatch flag to true , Used to indicate that the process should be rescheduled after it has been terminated , Select a new process , Assign the processor to it .

The third step : If the process still has descendants , All its descendants should be terminated , In case they become uncontrollable .

Step four : Release all resources occupied by the process ( Return to parent process or system ), Release process control block ( If the progress is in execution state , To schedule a process ).

Step five : The process will be terminated ( its PCB) From queue ( Or linked list ) Remove from , Wait for other programs to collect relevant information .

20, The purpose of process collaboration : information sharing , Improve the operation speed , modularization , convenient

21, Basic mode of interprocess communication :(1) Shared memory (2) message passing

22, Message passing is achieved through system calls , Slow , Useful for exchanging a small amount of data , Because there's no need to avoid conflict .

23, High speed of message passing in shared memory , A system call is required only when a shared memory area is created

Technology