Process Control
Process life cycle
Generate, run, pause, terminate
Process control
The operating system manages the state transition of the process through process control primitives. Common process control operations include:
-
Process creation:
-
Create a new process, allocate necessary resources to it, and initialize PCB.
-
After creation, the process enters the ready state, waiting for the scheduler to allocate CPU time.
-
-
Process cancellation:
-
Cancel (terminate) the process, reclaim the resources occupied by the process, and remove its PCB from the system.
-
Termination reasons may include normal program termination, user active termination, abnormal errors, etc.
-
-
Process blocking:
-
During the running process, if the process needs to wait for an event (such as I/O completion, signal arrival), it enters the blocking state.
-
After the process is blocked, the CPU will be released to allow other processes to execute.
-
-
Process wakeup:
- When the event that the blocked process is waiting for occurs, the process is awakened and enters the ready state.
- The wake-up operation is usually triggered by the operating system or other processes.
-
Change process priority number:
-
Adjust the priority of the process to change the priority of the process when scheduling.
-
A process with a higher priority will be scheduled for execution earlier than a process with a lower priority.
-
-
Process scheduling:
-
Select a process from the ready queue, switch it to the running state, and start execution.
-
The scheduler selects the appropriate process based on the scheduling algorithm (such as first-come-first-served, priority scheduling, time slice rotation, etc.).
-
Four process control primitives
In the operating system, the four commonly used process control primitives include:
1. Process blocking (Block)
-
Function: Convert a process in the running state to the blocked state.
-
Trigger condition: When a process performs I/O operations and waits for an event (such as a semaphore), it needs to enter the blocked state.
2. Process wakeup (Wakeup)
- Function: Convert a process in the blocked state to the ready state.
- Trigger condition: When the waiting event occurs (such as I/O completion, resource availability), the process is awakened and re-enters the ready state.
3. Process creation (Create)
-
Function: Create a new process and set it to the ready state.
-
Trigger condition: When the system or user needs to create a new task, the process creation primitive is called.
4. Process scheduling (Dispatch/Schedule)
-
Function: Switch the process in the ready state to the running state.
-
Trigger condition: When the CPU is idle or the time slice ends, the scheduler selects a process from the ready queue to execute.