Question

For the processes listed in the following table, which of the following scheduling schemes will give the lowest average turnaround time?

ProcessArrival TimeProcessing Time
A03
B16
C44
D62
Choose one option
Official answer and solution
Official answer
C
From
Official GATE 2015 answer key

Solution

Simulate each scheduling policy (FCFS, Non-preemptive SJF, SRTF, RR with quantum 2) and calculate the average turnaround time.

Given processes:

  • A: arrival = 0, burst = 3
  • B: arrival = 1, burst = 6
  • C: arrival = 4, burst = 4
  • D: arrival = 6, burst = 2
  1. Shortest Remaining Time First (SRTF):
  • t=0t = 0: Only A arrives. A runs until t=1t = 1.
  • t=1t = 1: B arrives (burst 6). A remaining burst is 2. Since 2<62 < 6, A continues. A finishes at t=3t = 3.
    Completion time of A =3= 3.
  • t=3t = 3: Only B is present (remaining 6). B runs from t=3t = 3 to 44.
  • t=4t = 4: C arrives (burst 4). B has remaining burst 5. Since 4<54 < 5, C preempts B! C runs from t=4t = 4 to 66.
  • t=6t = 6: D arrives (burst 2). C has remaining burst 2. D has burst 2. C continues (or D runs). C finishes at t=8t = 8.
    Completion time of C =8= 8.
  • t=8t = 8: Ready queue has D (burst 2) and B (remaining 5). D runs from t=8t = 8 to 1010.
    Completion time of D =10= 10.
  • t=10t = 10: B runs from t=10t = 10 to 1515.
    Completion time of B =15= 15.

Turnaround time (TAT=Completion−ArrivalTAT = \text{Completion} - \text{Arrival}):

  • A: 3−0=33 - 0 = 3
  • B: 15−1=1415 - 1 = 14
  • C: 8−4=48 - 4 = 4
  • D: 10−6=410 - 6 = 4
    Average TAT for SRTF =3+14+4+44=254=6.25= \frac{3 + 14 + 4 + 4}{4} = \frac{25}{4} = 6.25.

By optimality theorem of scheduling, Shortest Remaining Time First (SRTF) is provably optimal for minimizing average turnaround / waiting time among all scheduling algorithms. Hence, SRTF gives the lowest average turnaround time (Option C).

Final answer

C

Common trap

Confusing non-preemptive SJF with preemptive SRTF; non-preemptive SJF cannot preempt long process B once it starts.

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

Source

Paper
GATE 2015 Computer Science and Information Technology (CS) Session 3
Question
44 of 65, printed as CS Q.34
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.