Process Scheduling
Process Scheduling
Process scheduling is a low-level scheduling that is responsible for selecting a process from multiple ready processes, allocating CPU, and allowing it to run. Its goal is to efficiently utilize the CPU and meet the performance requirements of the system.
Main functions of process scheduling
Selecting a process:
- Select a process that is most suitable for the current operation from the ready queue and allocate the CPU to it.
Managing CPU allocation:
- Dynamically adjust the CPU allocation strategy so that CPU resources can be reasonably shared among processes.
Save and restore process context:
-
When switching CPU control, save the running state (context) of the current process;
-
Restore the running state of the scheduled process so that it can continue to run.
Fairness and priority control:
-
Ensure that all processes can compete fairly for the CPU;
-
Reasonably allocate the CPU according to scheduling strategies such as priority and urgency.
Support multiple scheduling algorithms:
- Support multiple algorithms such as first-come-first-served (FCFS), time slice rotation, and high response ratio priority (HRRF) to adapt to different system requirements.
Timing of process scheduling
Process scheduling is usually triggered in the following situations:
Process running ends:
- The current process has finished executing, the CPU is idle, and a new process needs to be scheduled to run.
Process enters the blocked state:
- The current process cannot continue to run due to I/O requests, waiting for resources, etc., and switches from the running state to the blocked state, and schedules other processes to run.
Time slice is exhausted (in time-sharing system):
- The time slice of the current process is exhausted, triggering process switching and allocating the CPU to the next process.
Priority preemption:
- In preemptive scheduling, when a higher priority process enters the ready queue, the current running process will be interrupted and the CPU will be allocated to the high priority process.
Process changes from the blocked state to the ready state:
- After the event that the blocking process is waiting for is completed, it will re-enter the ready state, which may trigger the scheduling of a new process.
Return after the system call is completed:
- After the system call or other system tasks are completed, the user process may need to be rescheduled.