Question:

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

Show Hint

Shortest Remaining Time First (SRTF) scheduling preempts the currently executing process if a newly arrived process has a shorter remaining execution time. Calculating turnaround time requires tracking completion times carefully.
Updated On: Apr 7, 2025
  • 22
  • 15
  • 37
  • 19
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is D

Solution and Explanation

To determine the average turnaround time using the Shortest Remaining Time First (SRTF) algorithm, we analyze the execution of processes:
  • Arrival Times: \( P_1 = 0 \), \( P_2 = 1 \), \( P_3 = 2 \), \( P_4 = 8 \)
  • Burst Times: \( P_1 = 10 \), \( P_2 = 13 \), \( P_3 = 6 \), \( P_4 = 9 \)
Step-by-step execution:
  • P1 starts at \( t = 0 \).
  • P2 arrives at \( t = 1 \), but since P1 has a shorter remaining time, it continues.
  • P3 arrives at \( t = 2 \) with a shorter burst time (6), so it preempts P1.
  • P3 finishes at \( t = 8 \).
  • P4 arrives at \( t = 8 \), but has a longer remaining time than P1, so P1 resumes.
  • P1 completes at \( t = 12 \).
  • P2 executes next, followed by P4.
Turnaround Times:
  • TAT(P1) = 12 - 0 = 12
  • TAT(P2) = 26 - 1 = 25
  • TAT(P3) = 8 - 2 = 6
  • TAT(P4) = 35 - 8 = 27
Average Turnaround Time:
\[ \frac{12 + 25 + 6 + 27}{4} = \frac{70}{4} = 19 \]

Thus, the correct answer is (D) 19.

Was this answer helpful?
0
0

Questions Asked in GATE CS exam

View More Questions