GATE / CS ARCHIVE

GATE CSE 2006 / QUESTION 6

SRTF process switches

Operating Systems · CPU Scheduling · Full GATE CSE 2006 paper

GATE 2006, Q6 1 mark · MCQ
Report issue

CPU Scheduling

Question 6, GATE 2006: Three CPU-bound processes arrive at times 0,2,6 and need 10,20,30 time units respectively. With shortest-remaining-time-first scheduling, how many context switches occur, excluding initial dispatch at time 0 and final termination?
Options:
(A) 1
(B) 2
(C) 3
(D) 4
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. At time 2 the first process has 8 units remaining, less than the new 20. At time 6 it has 4 remaining, less than 30.

2. It therefore runs 0–10, followed by the 20-unit process 10–30 and the 30-unit process 30–60. Excluding initial dispatch and final exit leaves two process switches, B.

3. Teaching check: Draw the CPU timeline 0–10:P1, 10–30:P2, 30–60:P3. An arrival is not automatically a preemption: compare its burst with the current remaining time. Only the changes P1→P2 and P2→P3 count under the exclusions in the question.

Original paper, page 1