GATE / CS ARCHIVE

GATE CSE 2014 SET 3 / QUESTION 32

GATE CSE 2014 Set 3 Q32

Operating Systems · CPU Scheduling · Full GATE CSE 2014 Set 3 paper

GATE 2014 Set 3, Q32 2 marks · NAT
Report issue

CPU Scheduling

Question 32, GATE 2014: Preemptive shortest-remaining-time-first scheduling is applied to processes (arrival,CPU burst), in ms: P1=(0,12), P2=(2,4), P3=(3,6), P4=(8,5). Find their average waiting time.
Tap to enlarge
Answer & solution

Official answer: 5.5

Step through it (8 steps)

Step 1: P1 runs 0–2, leaving 10. P2 arrives with burst 4 and preempts it. At time 3, P2 has 3 remaining, shorter than P3's 6, so P2 finishes at 6. Step 2: P3 then runs 6–12. When P4 arrives at 8, P3 has 4 remaining, less than P4's 5, so no preemption occurs. P4 runs 12–17, then P1 runs 17–27. Step 3: Waiting time equals completion−arrival−burst: P1=27−0−12=15; P2=6−2−4=0; P3=12−3−6=3; P4=17−8−5=4. The average is (15+0+3+4)/4=5.5 ms, assuming negligible switching cost.

Original paper, page 60 · Answer key