Process and Thread Notes-3

Process control

Create process
Assign a unique process label to the new process and apply for a blank PCB. If there is no PCB available, the creation will fail.
Allocate resources for the process. If the resources are insufficient, enter the waiting state.
Initialize PCB.
If the process scheduling queue can accommodate the new process, insert the new process into the ready queue and wait for it to be scheduled to run.
Terminating the process
There are three ways to terminate the process: normal end, abnormal end, and external intervention.
Find the PCB that needs to terminate the process.
If it is in the execution state, the execution of the process is terminated immediately, and then the CPU resources are allocated to other processes.
If there are child processes, all child processes are terminated.
Return the resources owned by the process to the operating system or parent process.
Remove the PCB from the queue.
Blocking process
When a process needs to wait for an event to complete, it can call a blocking statement to block itself, and then wait for other processes to wake it up.
Find the PCB corresponding to the identification number of the process to be blocked.
If the process is running, protect the scene, turn the status to blocked, and stop running.
Insert the PCB into the blocking queue to
wake up the process.
When the waiting time for the blocking process lock is completed, the relevant process ( For example, a process that provides data) uses a wake-up statement to wake up the process.
Find the corresponding PCB
in the blocking queue and move it out of the blocking queue, turn its state to ready,
move it into the ready queue, and wait for scheduling

Guess you like

Origin blog.csdn.net/weixin_43891021/article/details/114248928