Question

Consider the following set of processes that need to be scheduled on a single CPU. All the times are given in milliseconds.

Process NameArrival TimeExecution Time
A06
B32
C54
D76
E103

Using the shortest remaining time first scheduling algorithm, the average process turnaround time (in msec) is ____________________.

Official answer and solution
Official answer
7.2
From
Official GATE 2014 answer key

Solution

Construct the execution Gantt chart under Shortest Remaining Time First (SRTF) scheduling and calculate average turnaround time.

Given processes:

  • AA: Arrival 0, Burst 6
  • BB: Arrival 3, Burst 2
  • CC: Arrival 5, Burst 4
  • DD: Arrival 7, Burst 6
  • EE: Arrival 10, Burst 3

Execution trace:

  • [0,3][0, 3]: Process AA runs. At t=3t = 3, remaining burst of A=6−3=3A = 6 - 3 = 3.
  • At t=3t = 3: BB arrives with burst 2. Since 2<32 < 3, BB preempts AA.
  • [3,5][3, 5]: Process BB runs. At t=5t = 5, BB completes (CTB=5CT_B = 5).
  • At t=5t = 5: CC arrives with burst 4. Remaining: A(3),C(4)A (3), C (4). AA runs because 3<43 < 4.
  • [5,7][5, 7]: Process AA runs. At t=7t = 7, remaining burst of A=3−2=1A = 3 - 2 = 1.
  • At t=7t = 7: DD arrives with burst 6. Remaining: A(1),C(4),D(6)A (1), C (4), D (6). AA has shortest remaining time.
  • [7,8][7, 8]: Process AA runs and completes at t=8t = 8 (CTA=8CT_A = 8).
  • At t=8t = 8: Ready queue has C(4),D(6)C (4), D (6). CC runs.
  • [8,10][8, 10]: Process CC runs. At t=10t = 10, remaining burst of C=4−2=2C = 4 - 2 = 2.
  • At t=10t = 10: EE arrives with burst 3. Remaining: C(2),E(3),D(6)C (2), E (3), D (6). CC has shortest remaining time.
  • [10,12][10, 12]: Process CC runs and completes at t=12t = 12 (CTC=12CT_C = 12).
  • At t=12t = 12: Ready queue has E(3),D(6)E (3), D (6). EE runs.
  • [12,15][12, 15]: Process EE runs and completes at t=15t = 15 (CTE=15CT_E = 15).
  • [15,21][15, 21]: Process DD runs and completes at t=21t = 21 (CTD=21CT_D = 21).

Turnaround time (TAT=CT−ATTAT = CT - AT):

  • TATA=8−0=8TAT_A = 8 - 0 = 8
  • TATB=5−3=2TAT_B = 5 - 3 = 2
  • TATC=12−5=7TAT_C = 12 - 5 = 7
  • TATD=21−7=14TAT_D = 21 - 7 = 14
  • TATE=15−10=5TAT_E = 15 - 10 = 5

Sum of Turnaround Times = 8+2+7+14+5=36 msec8 + 2 + 7 + 14 + 5 = 36\text{ msec}.

Average Turnaround Time=365=7.2 msec\text{Average Turnaround Time} = \frac{36}{5} = 7.2\text{ msec}
Final answer

7.2

Common trap

Calculating average waiting time instead of average turnaround time.

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

Source

Paper
GATE 2014 Computer Science and Information Technology (CS) Session 1
Question
42 of 65, printed as CS Q.32
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.