Question

Consider a single processor system with four processes A, B, C, and D, represented as given below, where for each process the first value is its arrival time, and the second value is its CPU burst time.

A (0, 10), B (2, 6), C (4, 3), and D (6, 7).

Which one of the following options gives the average waiting times when preemptive Shortest Remaining Time First (SRTF) and Non-Preemptive Shortest Job First (NP-SJF) CPU scheduling algorithms are applied to the processes?

Choose one option
Official answer and solution
Official answer
B
From
Official GATE 2024 answer key

Solution

Construct the Gantt chart for both SRTF and NP-SJF, compute WT=TAT−BT\text{WT} = \text{TAT} - \text{BT} for each process, and find the averages.

  1. Preemptive Shortest Remaining Time First (SRTF):

    • t=0→2t = 0 \to 2: A runs for 22 units (remaining burst =8= 8). At t=2t = 2, B arrives with burst 6<86 < 8 and preempts A.
    • t=2→4t = 2 \to 4: B runs for 22 units (remaining burst =4= 4). At t=4t = 4, C arrives with burst 3<43 < 4 and preempts B.
    • t=4→7t = 4 \to 7: C runs to completion at t=7t = 7 (D arrives at t=6t = 6 with burst 77).
    • t=7→11t = 7 \to 11: B (remaining 44) runs to completion at t=11t = 11.
    • t=11→18t = 11 \to 18: D (burst 7<87 < 8) runs to completion at t=18t = 18.
    • t=18→26t = 18 \to 26: A (remaining 88) runs to completion at t=26t = 26.
    • Waiting times (WT=CT−AT−BT\text{WT} = \text{CT} - \text{AT} - \text{BT}):
      • WTA=26−0−10=16\text{WT}_A = 26 - 0 - 10 = 16
      • WTB=11−2−6=3\text{WT}_B = 11 - 2 - 6 = 3
      • WTC=7−4−3=0\text{WT}_C = 7 - 4 - 3 = 0
      • WTD=18−6−7=5\text{WT}_D = 18 - 6 - 7 = 5
    • Average WT (SRTF) =16+3+0+54=244=6= \frac{16 + 3 + 0 + 5}{4} = \frac{24}{4} = 6.
  2. Non-Preemptive Shortest Job First (NP-SJF):

    • t=0→10t = 0 \to 10: A starts at t=0t = 0 and runs to completion at t=10t = 10 (WTA=0\text{WT}_A = 0).
    • At t=10t = 10, B (burst 66), C (burst 33), and D (burst 77) are all in the ready queue; they execute in order of burst time: C (10→1310 \to 13), B (13→1913 \to 19), D (19→2619 \to 26).
    • Waiting times:
      • WTA=0\text{WT}_A = 0
      • WTC=10−4=6\text{WT}_C = 10 - 4 = 6
      • WTB=13−2=11\text{WT}_B = 13 - 2 = 11
      • WTD=19−6=13\text{WT}_D = 19 - 6 = 13
    • Average WT (NP-SJF) =0+6+11+134=304=7.5= \frac{0 + 6 + 11 + 13}{4} = \frac{30}{4} = 7.5.
Final answer

Option (B)

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

Source

Paper
GATE 2024 Computer Science and Information Technology - Set 2 (CS2)
Question
37 of 65
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.