Operating system~process status, conversion, control

The state of the process

The process in the operating system has five core states, namely the running state, the ready state, the blocking state, the creation state, and the termination state.
The running state, the ready state and the blocking state are the three most basic states.
Insert picture description here

Three basic states

A process is an execution of a program. During this execution process, sometimes the process is being processed by CPu, and sometimes it needs to wait for the CPU service. It can be seen that the state of the process will change in various ways. In order to facilitate the management of each process, the operating system needs to reasonably divide the process into several states.

The core difference between the three basic states is whether they are being executed on the CPU and if they can be executed on the CPU.

Insert picture description here

The other two states

These two states represent process creation and destruction
Insert picture description here

Process state transition

Insert picture description here
From the above figure, we can see that the running state to the blocking state is because a certain system call is sent, which is the process taking the initiative, and the blocking to the ready state is the state that the process can reach after passively completing a certain condition.

to sum up

Insert picture description here

Process control

Insert picture description here

What is process control

The main function of process control is to implement effective management of all processes in the system. It has functions such as creating new processes, canceling existing processes, and realizing process state transitions.

Simplified understanding: Anyway, process control is to achieve process state transition
Insert picture description here

How to achieve process control?

Use primitives to achieve process control.
The feature of primitives is that they are not allowed to be interrupted during execution and can only be done in one go. This uninterruptible operation is an atomic operation.
The primitives are implemented with "off interrupt instruction" and "on interrupt instruction".
Insert picture description here
Obviously, the power of off/on interrupt instruction is very large, and it must be a privileged instruction that is only allowed to be executed in the core state.

Process control will cause the transition of the process state. No matter which primitive, there are three types of things to do:
1. Update the information in the PCB (such as modifying the process status flag, saving the operating environment to the PCB, and restoring the operating environment from the PCB)
a. All process control primitives must modify the process status flag
. b. Deprive the CPU usage rights of the current running process. The operating environment needs to be saved
c. The operating environment must be restored before a process starts running
2. Insert the PCB into the appropriate queue
3. Allocate/recycle resources
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here

Guess you like

Origin blog.csdn.net/Shangxingya/article/details/113799269