GATE / CS ARCHIVE

GATE CSE 2007 / QUESTION 55

Shortest remaining time scheduling and waiting time

Operating Systems · CPU Scheduling · Full GATE CSE 2007 paper

GATE 2007, Q55 2 marks · MCQ
Report issue

CPU Scheduling

Question 55, GATE 2007: Shortest Remaining Time first schedules four processes: P1 arrives at 0 and requires 20 units; P2 at 15 requires 25; P3 at 30 requires 10; P4 at 45 requires 15. What is P2’s total waiting time?
Options:
(A) 5
(B) 15
(C) 40
(D) 55
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

Step through it (8 steps)

1. Approach. At each arrival compare remaining service, not original burst lengths. Draw the execution intervals and count only the intervals after P2 arrives during which it is ready but not running.

2. Derivation and interpretation. P1 runs from 0 to 20: at P2's arrival at 15, P1 has only 5 units left versus P2's 25. P2 runs 20–30, leaving 15; P3 then arrives with 10 and runs 30–40. P2 resumes at 40. When P4 arrives at 45, P2 has 10 left versus P4's 15, so P2 continues until 55. Its waiting intervals are 15–20 and 30–40, totaling 5+10=15 (B). Equivalently completion−arrival−execution=55−15−25=15.

Original paper, page 13