Question

Consider the following processes, with the arrival time and the length of the CPU burst given in milliseconds. The scheduling algorithm used is preemptive shortest remaining-time first.

Process | Arrival Time | Burst Time
P1 | 0 | 10
P2 | 3 | 6
P3 | 7 | 1
P4 | 8 | 3

The average turn around time of these processes is _____ milliseconds.

Official answer and solution
Accepted answers
8.2 to 8.3
From
Official GATE 2016 answer key

Solution

Build the preemptive Shortest Remaining Time First (SRTF) schedule Gantt chart and compute turnaround times.

Construct the timeline of process execution under preemptive SRTF scheduling:

  • At t=0t = 0: P1P_1 arrives with burst 10. P1P_1 starts executing.
  • At t=3t = 3: P2P_2 arrives with burst 6. Remaining burst of P1P_1 is 10−3=710 - 3 = 7. Since remaining time P2(6)<P1(7)P_2 (6) < P_1 (7), P1P_1 is preempted and P2P_2 runs.
  • At t=7t = 7: P3P_3 arrives with burst 1. P2P_2 has executed for 4 units, so its remaining burst is 6−4=26 - 4 = 2. Compare remaining bursts: P3(1)<P2(2)<P1(7)P_3 (1) < P_2 (2) < P_1 (7). Thus, P2P_2 is preempted and P3P_3 runs.
  • At t=8t = 8: P3P_3 completes (C3=8C_3 = 8). Concurrently, P4P_4 arrives with burst 3. Ready queue remaining bursts: P2=2,P4=3,P1=7P_2 = 2, P_4 = 3, P_1 = 7. Smallest is P2P_2 (2), so P2P_2 resumes.
  • At t=10t = 10: P2P_2 completes (C2=10C_2 = 10). Ready queue remaining bursts: P4=3,P1=7P_4 = 3, P_1 = 7. Smallest is P4P_4 (3), so P4P_4 runs.
  • At t=13t = 13: P4P_4 completes (C4=13C_4 = 13). Only P1P_1 remains with 7 units.
  • At t=20t = 20: P1P_1 finishes execution (C1=20C_1 = 20).

Calculate turnaround time (TAT=Completion Time−Arrival TimeTAT = \text{Completion Time} - \text{Arrival Time}) for each process:

  • P1P_1: TAT1=20−0=20 msTAT_1 = 20 - 0 = 20\text{ ms}
  • P2P_2: TAT2=10−3=7 msTAT_2 = 10 - 3 = 7\text{ ms}
  • P3P_3: TAT3=8−7=1 msTAT_3 = 8 - 7 = 1\text{ ms}
  • P4P_4: TAT4=13−8=5 msTAT_4 = 13 - 8 = 5\text{ ms}

Calculate the average turnaround time:

Average TAT=20+7+1+54=334=8.25 ms\text{Average TAT} = \frac{20 + 7 + 1 + 5}{4} = \frac{33}{4} = 8.25\text{ ms}
Final answer

8.25

Common trap

Computing average waiting time (10+1+0+2)/4=3.25 ms(10 + 1 + 0 + 2)/4 = 3.25\text{ ms} instead of turnaround time.

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2016 Computer Science and Information Technology (CS) Session 2
Question
57 of 65, printed as CS Q.47
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.