Concept
Control and coordinate the competition of multiple processes against the CPU
That is, according to a certain scheduling algorithm to select a process from the ready queue, the use of the CPU to the selected process
Scene
n processes ready, waiting for the upper M (m>=1) CPU to run, need to decide which process is assigned to which CPU to run
Solve
What: Scheduling algorithm (select Next by what principle), when: timing (when to choose), how: Scheduling process (How the selected process is running on the CPU)
Timing: When the kernel returns to the user state after the interrupt/exception/system call is processed (the change in the ready queue causes a reschedule)
If the process terminates gracefully (exits), the process is created as a result of an error termination (such as abort exception), a wait process becomes ready (wakeup), and a process changes from run state to ready state
or blocking state (waiting or interrupting)
Scheduling process: Process switching, one process letting out the CPU, the other consuming CPU, including saving the state of the original process and recovering the state of the new process
Example: Process a CPU, process B on the CPU, the entire process consists of saving the context of a process, modify the status of process a (update PCB), process A to the appropriate queue, the state of B
Set to run State, restore context from PCB in process B
An important concept: context switching overhead
Direct overhead includes CPU time for the kernel to complete the switchover (Save and restore registers, switch address space, etc.)
Overhead includes cache, buffer cache, TLB invalidation
the measurement index of scheduling algorithm
Throughput-the number of processes completed per unit of time
Turnaround time-The time each process has been made from the request to the completion of the run
Response time-from the time the request is made to the first response
CPU utilization--CPU doing effective work more time than the column
Wait time-the time each process waits in the ready queue
Operating system-CPU Scheduling