Machine-translated by Google. Questions are authored in English.
Top

Discussion

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?

  • A.22
  • B.15
  • C.37
  • D.19

Answer: D

The average turnaround time is 19 ms.

Under SRTF the process with the least remaining time runs, and an arrival can preempt it:

  • 0-2: P1 runs (P2 arrives at 1 with 13, more than P1's 9 left). At 2, P3 arrives with 6, less than P1's 8 left, and preempts.
  • 2-8: P3 runs to completion at 8. P4 arrives at 8 with 9.
  • 8-16: P1 (8 left) runs to completion at 16.
  • 16-25: P4 (9) runs; 25-38: P2 (13) runs.

\[ \begin{aligned} \text{TAT} &= (16-0) + (38-1) + (8-2) + (25-8) \\ &= 16 + 37 + 6 + 17 = 76 \\ \text{average} &= 76/4 = 19\ \text{ms} \end{aligned} \]

37 is P2's turnaround alone. 22 is close to the first-come first-served average, (10 + 22 + 27 + 30)/4 = 22.25, which ignores the shortest-remaining-time rule, and 15 matches no schedule of these processes.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.