CPU Scheduling
(Chapters 7-11)
CS 4410 Operating Systems
[R. Agarwal, L. Alvisi, A. Bracy, M. George, F.B. Schneider, E.G. Sirer, R. Van Renesse]
CPU Scheduling (Chapters 7-11) CS 4410 Operating Systems [R. - - PowerPoint PPT Presentation
CPU Scheduling (Chapters 7-11) CS 4410 Operating Systems [R. Agarwal, L. Alvisi, A. Bracy, M. George, F.B. Schneider, E.G. Sirer, R. Van Renesse] The Problem Youre the cook at State Street Diner customers continuously enter and place
[R. Agarwal, L. Alvisi, A. Bracy, M. George, F.B. Schneider, E.G. Sirer, R. Van Renesse]
2
3
4
5
Nomenclature warning: no agreement on any of these terms or the ones that follow
7
Turnaround Time Response Time
10
11
12
emacs
13
P2
P3
Time 0
12 15 18 Time 0
(12+15+18)/3 = 15 Average Turnaround Time: P1
P2 P3
18 3 6 Time 0
14
Average Turnaround Time: (3+6+18)/3 = 9
15
The Good The Bad The Ugly
– Average turnaround time very sensitive to schedule order – Not responsive to interactive jobs + Simple + Low-overhead + No Starvation
16
Average Response Time: (1+3+6+10+15)/5 = 7 P5
P1 P2
15 1 Time 0
P4 P3
3 6 10
†with preemption, remaining execution time
18
(1) Tasks (3) (2) (5) (4)
FIFO
(1) Tasks (3) (2) (5) (4)
SJF Time
19
20
The Good The Bad The Ugly
– Pessimal variance in turnaround time – Needs estimate of execution time – Can starve long jobs + Optimal average turnaround time
22
(1) Tasks (3) (2) (5) (4)
Round Robin (100 ms time slice)
(1) Tasks (3) (2) (5) (4)
Round Robin (1 ms time slice) Time
Rest of Task 1 Rest of Task 1
FIFO and SJF
(1) Tasks (3) (2) (5) (4)
Round Robin (1 ms time slice)
24
Time
(1) Tasks (3) (2) (5) (4)
FIFO and SJF
Tasks of same length that start ~same time
25 I/O Bound Tasks CPU Bound CPU Bound
Time
Issues I/O Request I/O Completes Issues I/O Request I/O Completes
compute go to disk wait 190 ms………….
100 ms quanta 100 ms quanta 100 ms quanta
compute go to disk
26
The Good The Bad The Ugly
– Context switch overhead – Mix of I/O and CPU bound –bad avg. turnaround time for equal length jobs + No starvation + Can reduce response time
27
28
29
30
System Interactive Batch Lowest priority Highest priority
31
Lowest priority Highest priority Quantum = 2 Quantum = 4 Quantum = 8 RR
Threads share code & data segments
green)
+ Improve cache hit ratio
32
Time
t1 t2 t3 t4 t1 t2 t3 t4
P1 P2 P3 P4
Time
t1 t2 t3 t4 t1 t2 t3 t4
P1 P2 P3 P4
*multiprocessor only