Skip to content
Official PYQ · 2016

GATE CS 2016 Set 2 Q47 — CPU Scheduling

Explain with AI
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.ProcessArrival TimeBurst TimeP_1010P_236P_371P_483\small \begin{array}{|c|c|c|} \hline \textbf{Process} & \textbf{Arrival Time} & \textbf{Burst Time}\\ \hline \text{$P\_1$} & 0 & 10 \\ \hline \text{$P\_2$} & 3 & 6 \\ \hline \text{$P\_3$} & 7 & 1 \\ \hline \text{$P\_4$} & 8 & 3 \\ \hline \end{array}The average turn around time of these processes is ___________ milliseconds.
View worked solution

Answer: 8.25

To find the average turnaround time, we trace the execution of the processes using the Preemptive Shortest Remaining Time First (SRTF) scheduling algorithm.

Gantt Chart Execution:

  • At t=0t = 0: Only P1P_1 is available. It runs for 33 ms.
  • At t=3t = 3: P2P_2 arrives. Remaining time of P1=7P_1 = 7 ms, and burst time of P2=6P_2 = 6 ms. Since 6<76 < 7, P2P_2 preempts P1P_1 and runs.
  • At t=7t = 7: P3P_3 arrives. Remaining time of P2=2P_2 = 2 ms, and burst time of P3=1P_3 = 1 ms. Since 1<21 < 2, P3P_3 preempts P2P_2 and runs.
  • At t=8t = 8: P3P_3 completes. P4P_4 arrives with burst time 33 ms. The remaining times are: P1(7)P_1 (7), P2(2)P_2 (2), and P4(3)P_4 (3). P2P_2 has the shortest remaining time, so it runs and completes at t=10t = 10.
  • At t=10t = 10: Remaining processes are P1(7)P_1 (7) and P4(3)P_4 (3). P4P_4 runs and completes at t=13t = 13.
  • At t=13t = 13: Finally, P1P_1 runs and completes at t=20t = 20.

The Gantt chart is represented as:

 P1  P2  P3  P2  P4  P1 03377881010131320\begin{array}{|c|c|c|c|c|c|} \hline \text{ } P_1 \text{ } & \text{ } P_2 \text{ } & \text{ } P_3 \text{ } & \text{ } P_2 \text{ } & \text{ } P_4 \text{ } & \text{ } P_1 \text{ } \\ \hline 0 \quad\quad 3 & 3 \quad\quad 7 & 7 \quad\quad 8 & 8 \quad\quad 10 & 10 \quad\quad 13 & 13 \quad\quad 20 \\ \hline \end{array}

Turnaround Time (TAT) Calculation:
Turnaround Time (TAT)=Completion Time (CT)−Arrival Time (AT)\text{Turnaround Time (TAT)} = \text{Completion Time (CT)} - \text{Arrival Time (AT)}

Process Arrival Time (AT) Burst Time (BT) Completion Time (CT) Turnaround Time (TAT)
P1P_1 0 10 20 20−0=2020 - 0 = 20
P2P_2 3 6 10 10−3=710 - 3 = 7
P3P_3 7 1 8 8−7=18 - 7 = 1
P4P_4 8 3 13 13−8=513 - 8 = 5

Average Turnaround Time=20+7+1+54=334=8.25 ms\text{Average Turnaround Time} = \frac{20 + 7 + 1 + 5}{4} = \frac{33}{4} = 8.25 \text{ ms}

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore CPU Scheduling questions