Skip to content
Official PYQ · 2015

GATE CS 2015 Set 3 Q34 — CPU Scheduling

Explain with AI

For the processes listed in the following table, which of the following scheduling schemes will give the lowest average turnaround time?ProcessArrival TimeProcess TimeA03B16C44D62\small \begin{array}{|c|c|c|} \hline \textbf{Process} & \textbf{Arrival Time} & \textbf{Process Time}\\ \hline \text{A} & 0 & 3 \\ \hline \text{B} & 1 & 6 \\ \hline \text{C} & 4 & 4 \\ \hline \text{D} & 6 & 2 \\ \hline \end{array}

Choose one option
View worked solution

Answer: C

Theoretically, Shortest Remaining Time First (SRTF) (preemptive SJF) is optimal and always yields the minimum average turnaround time (and average waiting time) for any given set of processes. Let us verify this by calculating the Turnaround Time (TAT=Completion Time−Arrival Time\text{TAT} = \text{Completion Time} - \text{Arrival Time}) for each scheduling scheme.

1. Shortest Remaining Time First (SRTF):

  • At t=0t = 0: Process AA runs.
  • At t=1t = 1: BB arrives. Remaining time of AA is 22, which is less than BB's burst 66. AA continues.
  • At t=3t = 3: AA completes. CT(A)=3\text{CT}(A) = 3. BB starts running.
  • At t=4t = 4: CC arrives (burst 44). Remaining time of BB is 55. Since 4<54 < 5, CC preempts BB.
  • At t=6t = 6: DD arrives (burst 22). Remaining time of CC is 22. Since DD and CC both have remaining time 22, we can run DD (or continue CC). Let's run DD.
  • At t=8t = 8: DD completes. CT(D)=8\text{CT}(D) = 8. CC resumes.
  • At t=10t = 10: CC completes. CT(C)=10\text{CT}(C) = 10. BB resumes.
  • At t=15t = 15: BB completes. CT(B)=15\text{CT}(B) = 15.

Calculating TAT for SRTF:

  • TAT(A)=3−0=3\text{TAT}(A) = 3 - 0 = 3
  • TAT(B)=15−1=14\text{TAT}(B) = 15 - 1 = 14
  • TAT(C)=10−4=6\text{TAT}(C) = 10 - 4 = 6
  • TAT(D)=8−6=2\text{TAT}(D) = 8 - 6 = 2
  • Average TAT = 3+14+6+24=6.25\frac{3 + 14 + 6 + 2}{4} = 6.25

2. Non-preemptive SJF:

  • AA runs from 00 to 33 (CT=3,TAT=3\text{CT} = 3, \text{TAT} = 3).
  • BB runs from 33 to 99 (CT=9,TAT=8\text{CT} = 9, \text{TAT} = 8).
  • DD runs from 99 to 1111 (CT=11,TAT=5\text{CT} = 11, \text{TAT} = 5).
  • CC runs from 1111 to 1515 (CT=15,TAT=11\text{CT} = 15, \text{TAT} = 11).
  • Average TAT = 3+8+11+54=6.75\frac{3 + 8 + 11 + 5}{4} = 6.75

3. First Come First Serve (FCFS):

  • AA runs 00 to 33 (TAT=3\text{TAT} = 3), BB runs 33 to 99 (TAT=8\text{TAT} = 8), CC runs 99 to 1313 (TAT=9\text{TAT} = 9), DD runs 1313 to 1515 (TAT=9\text{TAT} = 9).
  • Average TAT = 3+8+9+94=7.25\frac{3 + 8 + 9 + 9}{4} = 7.25

Thus, Shortest Remaining Time First (SRTF) gives the lowest average turnaround time.

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

Published
Report a correction
Keep exploringMore CPU Scheduling questions