GATE / CS ARCHIVE

GATE CSE 2011 / QUESTION 35

Preemptive shortest-remaining-time schedule

Operating Systems · CPU Scheduling · Full GATE CSE 2011 paper

GATE 2011, Q35 2 marks · MCQ
Report issue

CPU Scheduling

Question 35, GATE 2011: Processes P0,P1,P2 have (arrival,burst) times in ms of (0,9),(1,4),(2,9). Use preemptive shortest-job-first scheduling, reconsidering at arrivals or completions. What is their average waiting time?

(A) 5.0 ms
(B) 4.33 ms
(C) 6.33 ms
(D) 7.33 ms
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Step through it (6 steps)

P0 runs 0–1, then P1 with its shorter remaining time runs 1–5 despite P2 arriving at 2. P0 finishes its remaining 8 units during 5–13; P2 then runs 13–22. Waiting times are 13−0−9=4, 5−1−4=0 and 22−2−9=11. Average(4+0+11)/3=5ms, A.

At time 1, P0 has 8 units remaining and P1 needs 4, so preemption is required. At time 2, P1 has only 3 remaining, less than P0's 8 and newly arrived P2's 9, so no further preemption occurs. Waiting time is turnaround minus burst, not completion time alone. P0 waits from 1 to 5, P1 never waits, and P2 waits from 2 to 13. These intervals independently reproduce the total 15 ms waiting time.

Original paper, page 9 · Answer key