GATE CS 2025 Set 2 | Question 26

MCQ · 1 mark · −0.33

Processes \(P1\), \(P2\), \(P3\), \(P4\) arrive in that order at times 0, 1, 2, and 8 milliseconds respectively, and have execution times of 10, 13, 6, and 9 milliseconds respectively. Shortest Remaining Time First (SRTF) algorithm is used as the CPU scheduling policy. Ignore context switching times.

Which ONE of the following correctly gives the average turnaround time of the four processes in milliseconds?

  1. Option A: 22
  2. Option B: 15
  3. Option C: 37
  4. Option D: 19 (correct)

Answer

(D)

Explanation

SRTF always runs the ready process with the least remaining time, re-checking whenever a process arrives.

  • 0–2: \(P1\) runs. At time 1, \(P2\) needs 13 but \(P1\) only 9 more.
  • 2–8: \(P3\) (6) preempts \(P1\) (8 left) and finishes at 8.
  • 8–16: \(P4\) arrives needing 9, but \(P1\) needs only 8, so \(P1\) finishes at 16.
  • 16–25: \(P4\) (9) runs before \(P2\) (13).
  • 25–38: \(P2\) runs.

Turnaround time = completion − arrival: \(P1 = 16\), \(P2 = 37\), \(P3 = 6\), \(P4 = 17\). The average is \((16 + 37 + 6 + 17)/4 = 76/4 = 19\) ms; 37 is only \(P2\)'s turnaround time.

Answer: D