Consider the following set of processes, assumed to have arrived at time 0.…

2020

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 \(P_1, P_2, P_3, P_4\).

\(\begin{array}{|l|l|l|l|l|} \hline \text{Processes} & P_1 & P_2 & P_3 & P_4 \\ \hline \text{Burst time (in ms)} &8 & 7 & 2 & 4 \\ \hline \end{array}\)

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 _________ . 

Attempted by 133 students.

Show answer & explanation

Correct answer: 5.25

Key insight: all processes arrive at time 0. Compute the average turnaround time for non‑preemptive Shortest Job First (SJF) and for Round Robin (RR) with quantum = 4 ms (order P1, P2, P3, P4), then take the absolute difference.

  • SJF (non‑preemptive): order by burst time: P3 (2), P4 (4), P2 (7), P1 (8).

  • Completion times and turnaround times (arrival = 0): P3 completes at 2 (TAT = 2), P4 at 6 (TAT = 6), P2 at 13 (TAT = 13), P1 at 21 (TAT = 21).

  • Average turnaround time = (2 + 6 + 13 + 21) / 4 = 42 / 4 = 10.50 ms.

  • Round Robin (quantum = 4, order P1, P2, P3, P4): simulate in time slices.

  • Timeline: 0–4: P1 (rem 4); 4–8: P2 (rem 3); 8–10: P3 runs 2 and completes at 10; 10–14: P4 runs 4 and completes at 14; 14–18: P1 finishes at 18; 18–21: P2 finishes at 21.

  • Turnaround times: P1 = 18, P2 = 21, P3 = 10, P4 = 14. Average = (18 + 21 + 10 + 14) / 4 = 63 / 4 = 15.75 ms.

Answer: The absolute difference between the average turnaround times is |10.50 − 15.75| = 5.25 ms (rounded to two decimals).

Explore the full course: Gate Guidance By Sanchit Sir