CPU Scheduling Peng Lu CPU Scheduling 1 2
































- Slides: 32
CPU Scheduling Peng Lu
CPU Scheduling 1. 2. 3. 4. 5. Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling 2
1. Basic Concepts Alternating Sequence of CPU And I/O Bursts CPU Scheduler Preemptive Scheduling Dispatcher 3
Alternating Sequence of CPU And I/O Bursts 4
Histogram of CPU-burst Times 5
CPU Scheduler Short-term scheduler First-in, first-out (FIFO) 6
Preemptive Scheduling CPU scheduling decisions may take place when a process: 1. 2. 3. 4. Switches from running to waiting state Switches from running to ready state Switches from waiting to ready state Terminates Non-preemptive (1 and 4) Preemptive (All other) 7
Dispatcher involves: switching context switching to user mode jumping to the proper location in the user program to restart that program Dispatch latency 8
2. Scheduling Criteria CPU utilization Throughput Turnaround time Waiting time Response time 9
Optimization Criteria Max CPU utilization Max throughput Min turnaround time Min waiting time Min response time 10
3. Scheduling Algorithms First-come, First-served (FCFS) Shortest-Job-First (SJF) Priority Round-Robin (RR) Multilevel Queue Multilevel Feedback Queue 11
First-Come, First-Served (FCFS) Process P 1 P 2 P 3 Burst Time 24 3 3 If that the processes arrive in the order: P 1 , P 2 , P 3 , , The Gantt Chart for the schedule is: P 1 0 P 2 24 P 3 27 30 12
FCFS Scheduling (Cont. ) If that the processes arrive in the order P 2 , P 3 , P 1 The Gantt chart for the schedule is: P 2 0 P 3 3 P 1 6 30 13
Shortest-Job-First (SJF) Process P 1 P 2 P 3 P 4 Burst Time 6 8 7 3 14
Prediction of the Length of the Next CPU Burst 15
Priority Scheduling Process Burst Time Priority P 1 10 3 P 2 1 1 P 3 2 P 4 1 5 P 5 5 2 4 16
Priority Scheduling Indefinite blocking (Starvation) Aging 17
Round-Robin (RR) Time Quantum = 20 Process P 1 P 2 P 3 P 4 P 1 0 P 2 20 P 3 37 P 4 57 Burst Time 53 17 68 24 P 1 77 P 3 97 117 P 4 P 1 121 134 P 3 154 162 18
Time Quantum and Context Switch Time 19
Turnaround Time Varies With The Time Quantum 20
Multilevel Queue 21
Multilevel Feedback Queues 22
4. Multiple-Processor Scheduling More complex when multiple CPUs are available Homogeneous Load sharing Asymmetric multiprocessing 23
5. Real-Time Scheduling Hard real-time Soft real-time 24
Summary Optimization Criteria Max CPU utilization, throughput; Min turnaround, waiting and response time FCFS, SJF, Priority, RR Multilevel Queue and Feedback Queue 25
6. Algorithm Evaluation Deterministic modeling Queueing models Simulations Implementation 26
Operating System Examples Solaris scheduling Windows XP scheduling Linux scheduling 27
Operating System Examples : Solaris 2 Scheduling 28
Solaris Dispatch Table 29
Operating System Examples : Windows XP 30
Operating System Examples : Linux Scheduling Time-sharing Real-time 31
The Relationship Between Priorities and Timeslice length 32