State and conversion processes, process control

1. The status of the conversion process

1.1 Process state 1

Process is a program of the first performance. In the process of the execution, sometimes the process is being processed CPU, CPU sometimes need to wait for service, visibility, status of the process there will be a variety of changes. In order to facilitate the management of the processes, the operating system needs to process reasonably divided into several states.


Three basic operating status

  • Running state (Running): CPU occupancy, and run on the CPU

Note: single-core processor (CPU) environment, every moment at most one process is in the running state. (Dual-core environment can simultaneously run two processes in the state)

  • Ready state (Ready): already have operating conditions, but because there is no free CPU, but is temporarily unable to run

Process in this state already has all the resources needed in addition to the processor (CPU) outside, once processor, you can immediately run into the state began to run. That is: everything is ready, only a strong CPU.

  • Blocking state (Waiting / Blocked, also known as: wait state): waiting for an event can not be run temporarily

Such as: waiting for the operating system to assign a printer, wait for the results of disk read operations. The computer CPU is the most expensive components in order to improve CPU utilization, need to first other process requires allocation of resources in place to get the CPU service


The other two states

  • Create a state () New, also known as: New state: the process is being created, the operating system to allocate resources for the process of initializing PCB

The operating system needs to complete the creation process. Operating system for the system resources required for the process of allocating memory space, and create, initialize the PCB (eg: allocation for the process PID)

  • Termination state (Terminated, also known as: end-state): the process of being withdrawn from the system, the operating system resource recovery process has to revoke PCB

Run the end of the process (or due to a bug caused the process can not continue execution, such as array bounds error), required the revocation process.
The operating system needs to complete the work revocation process. The resources allocated to complete the recovery process, revocation process PCB, etc.

State transition process between 1.2

Here Insert Picture Description

  • Ready state -> operating mode: the process is scheduled, the recovery process for an operating environment, and modify the contents of the corresponding queues PCB.
  • Operating mode -> the ready state (switching process): the time slice, or other CPU preempted a high-priority process, the process must be kept operating environment, and modify the contents of the corresponding queues PCB.
  • Operating mode -> blocking state: waiting for allocation of system resources, or waiting for something happens (proactive behavior), need to maintain process operating environment, and modify the contents of the corresponding queues PCB.
  • Blocking state -> ready state: allocation of resources in place, waiting for the event (passive behavior), need to modify the PCB content and the corresponding queues. If you wait until that resource is needed for the process to allocate system resources.
  • Creating state -> ready state: to create a system to complete the work related to the process, the need to modify the PCB content and the corresponding queues.
  • Runnable -> terminate state: the process to finish, or an error is encountered during the operation irreparable

2. Process Control

2.1 Basic Concepts

What is the process control?
The main function is to process control system for all processes to implement effective management, it has created a new process, the process has been revoked, the state of progress towards conversion.

Simplify understanding: Anyway, process control is how to achieve progress towards conversion process state control? With "primitive" to achieve

How to achieve process control?
usePrimitiveAchieve process control. PrimitiveFeatureDuring the execution isMust not be interruptedOnly one go. This can not be interrupted operation that isAtomic operation.
Primitive use of "Disable interruptsInstruction "and"The opening breakInstructions "to achieve
Obviously,Off / On interrupt instructionThe authority is very large, it would be only allowed inCore stateUnder executionPrivileged instruction

2.2 Process control related primitives

Study Skills: Process control will lead to the conversion process state. Whichever primitive, to do nothing but three things:

  1. Update information in the PCB (such as modifying the process status flag, the operating environment to save PCB, PCB recover from the operating environment)

    a. All process control primitives will modify the process state flag
    b. deprivation of CPU currently running processes necessarily need to save the right to use its operating environment
    c. before the start of a process run is bound to restore its operating environment

  2. The PCB is inserted into the appropriate queue
  3. Allocation / resource recovery
  • Creation process

    • Create a primitive(No -> Create state -> ready state)
      • Application blank PCB
      • Allocate the resources required for the new process
      • PCB initialization
      • The PCB is inserted into the ready queue
    • Events that cause process creation
      • User Login: time-sharing system, the user login is successful, the system will establish a new process for
      • Job scheduling: multi-batch system, when there is a new job into memory, will for the establishment of a new process
      • Service: the user made some requests to the operating system, creates a new process to handle the request
      • Application requests: a request by the user process initiative to create a child process
  • Termination process

    • Cancel the original language(Ready state / blocking state / operating mode -> terminate state -> No)
      • Found terminate the process from the set PCB PCB
      • If the process is running, immediately denied CPU, the CPU allocated to other processes
      • Terminate all of its child processes
      • All the resources the process has returned to the parent process or operating system
      • Delete PCB
    • Events that cause the process to terminate
      • Normal end
      • Abend
      • Outside intervention

Blocking and wake-up process 2

  • Blocked processes
    • Blocking primitives(Operating mode -> blocking state)
      • To find a blocked process corresponding PCB
      • Protection process running to the scene, PCB status information to "blocking state", temporarily stop the process running
      • The PCB is inserted into a corresponding sequence of events waiting
    • Cause the process to block events
      • We need to wait for a resource allocation system
      • We need to wait for mutual cooperation of other processes to complete the work
  • Wake-up process
    • Wake primitive(Blocking state -> ready state)
      • In the event queue waiting to find PCB
      • The PCB is removed from the waiting queue, a process is provided for the ready state
      • The PCB is inserted into the ready queue, waiting to be scheduled
    • Course of events caused by wake
      • Waiting for the event:It should be anything because anything blocking wake

  • The process of switching
    • Switching primitive(Operating mode -> blocking state / ready state ready state -> operating mode)
      • The operating environment information into PCB
      • PCB into the respective queue
      • Select another process execution, and update its PCB
      • According to the new PCB recovery process required to run the environment
    • Events that cause the process of switching
      • The current course of events to pieces
      • There are a higher priority process arrives
      • Actively blocking the current process
      • The current process is terminated

  1. More than kingly notes are from PubMed ↩︎

  2. Wake blocking primitives primitives must be used in pairs ↩︎

Published 50 original articles · won praise 5 · Views 1517

Guess you like

Origin blog.csdn.net/qq_42483691/article/details/104866064