GATE / CS ARCHIVE

GATE CSE 2017 SET 1 / QUESTION 24

GATE CSE 2017 Set 1 Q24

Operating Systems · CPU Scheduling · Full GATE CSE 2017 Set 1 paper

GATE 2017 Set 1, Q24 1 mark · NAT
Report issue

CPU Scheduling

Question 24, GATE 2017: Processes P1,P2,P3,P4 have (arrival,CPU burst) in ms: (0,7),(3,3),(5,5),(6,2). Use preemptive shortest-remaining-time-first scheduling and find average waiting time.
Tap to enlarge
Answer & solution

Official answer: 3.0

Our answer: 3

Step through it (7 steps)

1. Run P1 at t=0. At t=3 it has 4 ms left, so newly arrived P2 with 3 ms preempts it. At t=5 P2 has only 1 ms left, less than P3’s 5, so P2 continues to completion at 6.

2. At t=6 choose P4’s 2 ms over P1’s 4 and P3’s 5. P4 completes at 8, P1 runs 8–12, then P3 runs 12–17.

3. Waiting=completion−arrival−burst. For P1,P2,P3,P4 these are 12−0−7=5,6−3−3=0,17−5−5=7,8−6−2=0. Average=(5+0+7+0)/4=3 ms.

Original paper, page 12 · Answer key