GateAI
CPU and I/O Scheduling

GATE CSE 2017 Set 1 · Q24

NAT1 markMedium

Time

Consider the following CPU processes with arrival times (in milliseconds) and length of CPU bursts (in milliseconds) as given below : If the pre-emptive shortest remaining time first scheduling algorithm is used to schedule the processes, then the average waiting time across all processes is ________ milliseconds.

GATE CSE 2017 Set 1 Q24 diagram

Your answerNumerical answer

Enter a value to check

Solution

Step-by-step verified solution

Official answer: 3 (±0)

CPU and I/O Scheduling

We schedule the processes using the Preemptive Shortest Remaining Time First (SRTF) algorithm:

  • At time t=0t = 0: Process P1P_1 arrives with remaining burst time 77. P1P_1 executes.

  • At time t=3t = 3: P2P_2 arrives with burst time 33. Remaining burst time of P1P_1 is 7−3=47 - 3 = 4. Since Remaining(P2)=3<4\text{Remaining}(P_2) = 3 < 4, P1P_1 is preempted and P2P_2 starts execution.

  • At time t=5t = 5: P3P_3 arrives with burst time 55. Remaining burst time of P2P_2 is 3−2=1<53 - 2 = 1 < 5. So P2P_2 continues.

  • At time t=6t = 6: P4P_4 arrives with burst time 22. P2P_2 finishes execution at t=6t = 6.

  • At time t=6t = 6: Ready queue has P4P_4 (remaining: 22), P1P_1 (remaining: 44), P3P_3 (remaining: 55). The shortest is P4P_4, so P4P_4 runs from t=6t = 6 to t=8t = 8 and finishes at t=8t = 8.

  • At time t=8t = 8: Ready queue has P1P_1 (remaining: 44) and P3P_3 (remaining: 55). P1P_1 runs from t=8t = 8 to t=12t = 12 and finishes at t=12t = 12.

  • At time t=12t = 12: P3P_3 runs from t=12t = 12 to t=17t = 17 and finishes at t=17t = 17.

Gantt Chart:

[P1:0−3]∣[P2:3−6]∣[P4:6−8]∣[P1:8−12]∣[P3:12−17][P_1: 0-3] \mid [P_2: 3-6] \mid [P_4: 6-8] \mid [P_1: 8-12] \mid [P_3: 12-17]

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

  • For P1P_1: CT=12\text{CT} = 12, TAT=12−0=12\text{TAT} = 12 - 0 = 12, WT=12−7=5\text{WT} = 12 - 7 = 5

  • For P2P_2: CT=6\text{CT} = 6, TAT=6−3=3\text{TAT} = 6 - 3 = 3, WT=3−3=0\text{WT} = 3 - 3 = 0

  • For P3P_3: CT=17\text{CT} = 17, TAT=17−5=12\text{TAT} = 17 - 5 = 12, WT=12−5=7\text{WT} = 12 - 5 = 7

  • For P4P_4: CT=8\text{CT} = 8, TAT=8−6=2\text{TAT} = 8 - 6 = 2, WT=2−2=0\text{WT} = 2 - 2 = 0

Average Waiting Time=5+0+7+04=124=3.0 ms\text{Average Waiting Time} = \frac{5 + 0 + 7 + 0}{4} = \frac{12}{4} = 3.0\text{ ms}

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 Q24 of the GATE CSE 2017 Set 1 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. 2 of them are 1-mark NAT questions like this one, and it is the only one in GATE CSE 2017 Set 1.

How GATE tests CPU and I/O Scheduling

More from GATE CSE 2017 Set 1

Share this solution

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

GateAI solution cardGATE CSE 2017 Set 1 · Q24 · NAT

Consider the following CPU processes with arrival times (in milliseconds) and length of CPU bursts (in milliseconds) as given below : If the pre-emptive shortest remaining time first scheduling algorithm is used to schedule the processes, then the average waiting time across all processes is … milliseconds.

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.