IAE Academy

GATE 2025 CS2 Q.26: solution and answer

GATE 2025 · CS2Q.26 · 1 mark · MCQ

Processes 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. (A)

    22

  2. (B)

    15

  3. (C)

    37

  4. (D)

    19

See the question in the paper

Answer and solution

ANSWER

The average turnaround time is 19 ms, option (D).

Official answer: DSource: Official answer key, GATE 2025 CS2 (IIT Roorkee)

  1. Tabulate the processes: SRTF always runs the process with the least remaining time, and re-decides whenever a process arrives.

  2. From to only is present and runs, so its remaining time falls to 9. At , arrives with 13, which is more than 9, so continues.

  3. At , has 8 left and arrives with 6. Since , preempts .

  4. runs from 2 to 8 and completes at . No other arrival happens before that, so it is not interrupted. arrives at .

  5. At the remaining times are , , . is the shortest, so it runs from 8 to 16 and completes at 16. No new process arrives during this time.

  6. Next, (9) is shorter than (13), so runs from 16 to 25 and then runs from 25 to 38.

  7. Gantt chart:

  8. Turnaround time = completion time arrival time: , , , .

  9. Average ms, which is option (D).

KEY IDEA

SRTF is preemptive shortest-job-first: at every arrival and completion, run the process with the least remaining time. Turnaround time is completion time minus arrival time, not minus the start of execution.

WATCH OUT FOR

Treating the schedule as non-preemptive SJF, or using waiting time or completion time instead of turnaround time. Another slip is to let (6) wait for to finish, or to subtract 0 instead of the arrival time for and .

From the GATE 2025 CS2 paper. Every question of this paper · Download the full paper · All 8 CPU scheduling questions, with notes

More CPU scheduling questions