GateAI
CPU and I/O Scheduling

GATE CSE 2024 Set 2 · Q37

MCQ2 marksMedium

Time

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?

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: B) SRTF = 6, NP-SJF = 7.5

CPU and I/O Scheduling

### 1. Preemptive Shortest Remaining Time First (SRTF)

Let the given processes be:

  • A: Arrival Time (AT)=0(\text{AT}) = 0, Burst Time (BT)=10(\text{BT}) = 10

  • B: AT=2\text{AT} = 2, BT=6\text{BT} = 6

  • C: AT=4\text{AT} = 4, BT=3\text{BT} = 3

  • D: AT=6\text{AT} = 6, BT=7\text{BT} = 7

Gantt Chart Execution:

  • Time 00 to 22: Process A executes (remaining time of A=8\text{A} = 8).

  • Time 22 to 44: Process B arrives with remaining time 6<86 < 8, so B preempts A and executes (remaining time of B=4\text{B} = 4).

  • Time 44 to 77: Process C arrives with remaining time 3<43 < 4, so C preempts B and runs to completion (at t=7t = 7).

  • Time 77 to 1111: At t=7t = 7, ready queue has B (rem = 4), D (arrived at t=6t=6, rem = 7), and A (rem = 8). Process B has the shortest remaining time and runs to completion (at t=11t = 11).

  • Time 1111 to 1818: Process D (rem = 7) runs to completion (at t=18t = 18).

  • Time 1818 to 2626: Process A (rem = 8) runs to completion (at t=26t = 26).

Turnaround Time (TAT = Completion Time - Arrival Time) and Waiting Time (WT = TAT - Burst Time):

  • Process A: CT=26\text{CT} = 26, TAT=26−0=26\text{TAT} = 26 - 0 = 26, WT=26−10=16\text{WT} = 26 - 10 = 16

  • Process B: CT=11\text{CT} = 11, TAT=11−2=9\text{TAT} = 11 - 2 = 9, WT=9−6=3\text{WT} = 9 - 6 = 3

  • Process C: CT=7\text{CT} = 7, TAT=7−4=3\text{TAT} = 7 - 4 = 3, WT=3−3=0\text{WT} = 3 - 3 = 0

  • Process D: CT=18\text{CT} = 18, TAT=18−6=12\text{TAT} = 18 - 6 = 12, WT=12−7=5\text{WT} = 12 - 7 = 5

Average WT for SRTF=16+3+0+54=244=6\text{Average WT for SRTF} = \frac{16 + 3 + 0 + 5}{4} = \frac{24}{4} = 6

---

### 2. Non-Preemptive Shortest Job First (NP-SJF)

Gantt Chart Execution:

  • Time 00 to 1010: Process A arrives first at t=0t = 0 and executes non-preemptively until completion at t=10t = 10.

  • At t=10t = 10, all remaining processes are ready: B (BT = 6), C (BT = 3), D (BT = 7).

  • Time 1010 to 1313:C has the shortest burst time (3), so C executes until t=13t = 13.

  • Time 1313 to 1919:B has the next shortest burst time (6), so B executes until t=19t = 19.

  • Time 1919 to 2626:D executes until t=26t = 26.

Turnaround Time and Waiting Time:

  • Process A: CT=10\text{CT} = 10, TAT=10−0=10\text{TAT} = 10 - 0 = 10, WT=10−10=0\text{WT} = 10 - 10 = 0

  • Process B: CT=19\text{CT} = 19, TAT=19−2=17\text{TAT} = 19 - 2 = 17, WT=17−6=11\text{WT} = 17 - 6 = 11

  • Process C: CT=13\text{CT} = 13, TAT=13−4=9\text{TAT} = 13 - 4 = 9, WT=9−3=6\text{WT} = 9 - 3 = 6

  • Process D: CT=26\text{CT} = 26, TAT=26−6=20\text{TAT} = 26 - 6 = 20, WT=20−7=13\text{WT} = 20 - 7 = 13

Average WT for NP-SJF=0+11+6+134=304=7.5\text{Average WT for NP-SJF} = \frac{0 + 11 + 6 + 13}{4} = \frac{30}{4} = 7.5

Therefore, SRTF=6\text{SRTF} = 6 and NP-SJF=7.5\text{NP-SJF} = 7.5, matching option (B).

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

This CPU and I/O Scheduling previous year question is Q37 of the GATE CSE 2024 Set 2 paper. Find more GATE CSE PYQs on CPU and I/O Scheduling in Operating Systems, or browse all GATE CSE PYQs.

Free diagnostic

Where do you stand for GATE?

Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related CPU and I/O Scheduling PYQs now with no account.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

CPU and I/O Scheduling in GATE CSE

CPU and I/O Scheduling has 25 GATE CSE PYQs across 22 papers from 2011 to 2026. 7 of them are 2-mark MCQs like this one, and it is the only one in GATE CSE 2024 Set 2.

How GATE tests CPU and I/O Scheduling

More from GATE CSE 2024 Set 2

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2024 Set 2 · Q37 · MCQ

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?

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.