Three processes A, B and C each execute a loop of 100 iterations. In each…

2014

Three processes A, B and C each execute a loop of 100 iterations. In each iteration of the loop, a process performs a single computation that requires tc CPU milliseconds and then initiates a single I/O operation that lasts for tio milliseconds. It is assumed that the computer where the processes execute has sufficient number of I/O devices and the OS of the computer assigns different I/O devices to each process. Also, the scheduling overhead of the OS is negligible. The processes have the following characteristics:

\(\begin{array}{} \textbf{Process id} & \textbf{$t_c$} & \textbf{$t_{io}$} \\\textbf{A} & \text{100 ms} & \text{500 ms} \\\textbf{B} & \text{350 ms} & \text{500 ms}\\\textbf{C} & \text{200 ms} & \text{500 ms} \\\end{array}\)

The processes A, B, and C are started at times 0, 5 and 10 milliseconds respectively, in a pure time sharing system (round robin scheduling) that uses a time slice of 50 milliseconds. The time in milliseconds at which process C would complete its first I/O operation is ___________.

Attempted by 112 students.

Show answer & explanation

Correct answer: 1000

Answer: 1000 ms

Explanation: Simulate the round robin CPU schedule with 50 ms time slices until process C has received its full 200 ms of CPU time, then add the 500 ms I/O duration.

  1. 0–50 ms: Process A runs for 50 ms (A remaining CPU = 50 ms). B and C arrive at 5 ms and 10 ms and wait.

  2. 50–100 ms: Process B runs for 50 ms (B remaining CPU = 300 ms).

  3. 100–150 ms: Process C runs for 50 ms (C remaining CPU = 150 ms).

  4. 150–200 ms: Process A runs its remaining 50 ms (A remaining CPU = 0) and immediately starts its I/O at 200 ms.

  5. 200–250 ms: Process B runs (B remaining CPU = 250 ms).

  6. 250–300 ms: Process C runs (C remaining CPU = 100 ms).

  7. 300–350 ms: Process B runs (B remaining CPU = 200 ms).

  8. 350–400 ms: Process C runs (C remaining CPU = 50 ms).

  9. 400–450 ms: Process B runs (B remaining CPU = 150 ms).

  10. 450–500 ms: Process C runs its final 50 ms (C remaining CPU = 0) and starts its I/O at 500 ms.

Therefore, process C's I/O (which lasts 500 ms) completes at 500 + 500 = 1000 ms.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Gate Guidance By Sanchit Sir