Operating system - process management (Processing management)

First, the composition of the process

Process usually consists of program, data and process control block (Process Control Block, PCB).

Second, the state of the process and state switching

  The discontinuity of the process execution determines that the process may have multiple states. The three most basic states are as follows

  ① Ready state, when the process has been allocated all necessary resources except the CPU, as long as the CPU is obtained, it can run immediately. The state of the process at this time is called the ready state. In a system, multiple processes may be in the ready state, and they are usually queued in a queue, called the ready queue.

  ② In the execution state, the process has obtained the CPU and its program is being executed. In a uniprocessor system, only one process is executing, and in a multiprocessor system, multiple processes are executing.

  ③ Blocking state, when the thread in the executing state is suspended due to an event and cannot continue to execute, it will abandon the processor and be in a suspended state. The state of the process at this time is called the blocking state, or the waiting state or the blocking state. For example, IO requests, applying for cache space, etc., the blocked processes will also be arranged in a queue, and may also be arranged in multiple queues according to different blocking reasons.

  Explanation: The above figure shows the mutual transformation between the three basic states.

  In addition to the above three basic states, in some systems, a new suspended state is added. The reasons for introducing the suspended state are as follows

  ① The request of the end user, when the end user finds a suspicious problem during the running of his own program, he hopes to temporarily stop his own program, even if the executing process is suspended; if the user process is in a ready state at this time and is not executed , the process does not accept scheduling temporarily, so that the user can study its execution or modify the program, this state is called the suspended state.

  ② The parent process requests, sometimes the parent process wants to suspend one of its own child processes in order to examine and modify the child process, or coordinate the activities between the child processes.

  ③ The need for load regulation, when the workload in the real-time system is heavy and may affect the control of real-time tasks, the system can suspend some unimportant processes to ensure the normal operation of the system.

  ④ The needs of the operating system, the operating system sometimes wants to suspend certain processes in order to check the running resource usage or perform accounting.

  After the introduction of the suspended state, the following state transitions have been added

  ① Active ready -> static ready, when the process is in the ready state that is not suspended, it is called the active ready state; when it is suspended, it becomes the static ready state, and the process in the static ready state does not accept scheduling.

  ② Active blocking -> static blocking, when the process is in an unsuspended blocking state, it is called an active blocking state; when suspended, it becomes a static blocking state, and the process in this state is in the expected event after the occurrence of the event. , which will go from quiescent blocked to quiescent ready.

  ③ Stationary ready -> Active ready, use the activation primitive to activate.

  ④ Quiet

Stop Blocking -> Active Blocking, activated using the activation primitive.

  For process management, there are also two common states, the creation state and the termination state.

  ① To create a state, it generally takes two steps to create a process. First, common PCB for a new process, and fill in the necessary management information; secondly, transfer the process to the ready state and insert it into the ready queue. When a new process is created, the system allocates a PCB to it, and fills in the process flag and other information, but because the necessary resources or other information (such as memory) for the process have not been allocated, at this time, although the process has a PCB, but It does not enter the memory itself, that is, the creation work has not been completed, and the process cannot be scheduled to run at this time, and its state is the creation state.

  ② In the termination state, the termination of the process also requires two steps. First, wait for the aftermath of the operating system, and second, clear its PCB and return the PCB space to the operating system. The process that enters the terminated state can no longer be executed, but a record is still kept in the operating system, which saves the status code and some timing statistics for other processes to collect. Once other processes complete the information extraction of the terminated process, the operation The system will delete the process.

  Description: The above are the transitions between the seven states.

3. Communication between processes

1. Mutual exclusion

2. Sync

3. Semaphore

PV operation

monitor

4. Deadlock

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324978220&siteId=291194637