[002 Operating system] Process state and state transition diagram?

1. The status of the process

1. Created state 2. Ready state 3. Running state 4. Blocked state 5. Terminated state

Picture source: Family bucket of basic knowledge of processes and threads, a set of 30 pictures to take away_Linux_小林coding_InfoQ Writing Community

  • NULL -> Creation state : the first state when a new process is created;

  • Creation state -> Ready state : When the process is created and initialized, and everything is ready to run, it becomes ready state. This process is very fast;

  • Ready state -> Running state : After the process in the ready state is selected by the process scheduler of the operating system, it is assigned to the CPU to officially run the process;

  • Running state -> End state : When the process has finished running or has an error, it will be processed by the operating system as an end state;

  • Running state -> Ready state : During the running process of a process in the running state, because the running time slice allocated to it is used up, the operating system will change the process to the ready state, and then select another process to run from the ready state;

  • Running state -> blocking state : when the process requests an event and must wait, such as requesting an I/O event;

  • Blocked state -> ready state : When the event that the process is waiting for is completed, it changes from the blocked state to the ready state;

Three basic states of a process

Ready state: When the process has been allocated all the necessary resources except the CPU, it can be executed immediately as long as the processor is obtained, and the process state at this time is called the ready state.

Execution state: When a process has obtained a processor (CPU) and its program is being executed on the processor, the process state at this time is called the execution state.

Blocked state: When an executing process cannot execute due to waiting for an event to occur, it gives up the processor and is in a blocked state. For example, waiting for I/O to complete, applying for buffers that cannot be satisfied, waiting for letters (signals), etc.

When the application program operates on the device driver, if the device resource cannot be obtained, the blocking IO will suspend the thread corresponding to the application program until the device resource can be obtained. For non-blocking IO, the corresponding thread of the application will not be suspended, it will either poll and wait until the device resources are available, or give up directly.


2. How to create a process

1. System initialization;

2. A process starts a child process during operation;

3. The user's interactive request creates a new process (such as double-clicking qq);

4. Initialization of a batch job (applied only in mainframe batch systems).

A batch job means performing the same operation on each object, which can be done mechanically or procedurally. For example, if we want to move all the files in one folder to another folder on the computer, we can select and move them all at once. This is batch processing.

 

Guess you like

Origin blog.csdn.net/qq_41709234/article/details/131885979