CS401 CPU Scheduling Exercise Problem 2 Solution FINAL
CS401 CPU Scheduling Exercise Problem 2 Solution FINAL
Problem 2
Solutions
First Come First Served
0 8 17 23 24 27
P1 P4 P2 P3 P5
Avg. Wait = 0+8‐1+17‐2+23‐2+24‐3 = 0+7+15+21+21=64/5 = 12.8 AVG TAT = 8+17‐1+23‐2+24‐2+27‐3 = 8+16+21+22+24=91/5=18.2
Non‐Preemptive Priority
0 8 14 15 24 27
P1 P2 P3 P4 P5
Avg. Wait = 8‐2+14‐2+15‐1+24‐3 = 6+12+14+21 = 53/5=10.6ms AVG TAT = 8+14‐2+15‐2+24‐1+27‐3 = 8+12+13+23+24=80/5=16ms
Preemptive Priority
0 1 2 8 9 17 20 27
P1 P4 P2 P3 P4 P5 P1
Avg. Wait Time = 0+20‐1+2‐2+8‐2+9‐2+17‐3 = 0+19+0+6+7+14 = 46/5=9.2ms AVG TAT = 27+8‐2+9‐2+16+20‐3 = 73/5 = 14.6ms
Round Robin (1ms Quantum)
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
P1 P4 P2 P3 P5 P1 P4 P2 P5 P1 P4 P2 P5 P1 P4 P2 P1 P4 P2 P1 P4 P2 P1 P4 P1 P4 P4
Wait Time P1 = 0+4+3+3+2+2+1+1 = 16
Wait Time P2 = 0+4+3+3+2+2+2+1 = 17
Wait Time P3 = 1
Wait Time P4 = 4+4+3+2+3+2+1 = 19
Wait Time P5 = 1+3+3 = 7
Avg Wait Time = 60/5 = 12ms
Avg TAT =25+21+2+26+10 = 84/5 = 16.8
Premptive Priority has shortest wait and shortest TAT