Consider the following set of processes, assumed to have arrived at time 0. Consider the CPU scheduling algorithms Shortest Job First (SJF) and Round Robin (RR). For RR, assume that the processes are scheduled in the order P1, P2, P3, P4.
If the time quantum for RR is 4 ms, then the absolute value of the difference between the average turnaround times (in ms) of SJF and RR (round off to 2 decimal places is_______.
Correct Answer:
5.25
Solution:
For RR: Processes are scheduled in order P1, P2, P3, P4
Time quantum = 4ms
Process | AT | BT | CT | TAT = CT - AT |
P1 | 0 | 8 | 18 | 18 |
P2 | 0 | 7 | 21 | 21 |
P3 | 0 | 2 | 10 | 10 |
P4 | 0 | 4 | 14 | 14 |
Avg. TAT =
For SJF:
Process | AT | BT | CT | TAT = CT - AT |
P1 | 0 | 8 | 21 | 21 |
P2 | 0 | 7 | 13 | 13 |
P3 | 0 | 2 | 2 | 2 |
P4 | 0 | 4 | 6 | 6 |
Avg. TAT =
Absolute value of the difference between the average TAT of SJF and RR
= | 15.75 - 10.5 |= 5.25 ms