GATE / CS ARCHIVE

GATE CSE 2024 SET 2 / QUESTION 37

Compare preemptive and nonpreemptive shortest-job schedules

Operating Systems · CPU Scheduling · Full GATE CSE 2024 Set 2 paper

GATE 2024 Set 2, Q37 2 marks · MCQ
Report issue

CPU Scheduling

Question 37, GATE 2024: Four processes have (arrival,burst): A(0,10), B(2,6), C(4,3), D(6,7). Find average waiting times for SRTF and nonpreemptive SJF. A 6,7; B 6,7.5; C 7,7.5; D 7,8.5.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Step through it (2 schedules)

Approach: Draw a separate timeline for each policy, then use waiting=completion−arrival−burst.

1. Derivation. SRTF runs A0–2, B2–4, C4–7, B7–11, D11–18, A18–26. Completion times A26, B11, C7, D18 give waiting times 16, 3, 0, 5 after subtracting arrival and burst, average 24/4=6. Nonpreemptive SJF runs A0–10, C10–13, B13–19, D19–26, giving waiting times 0, 11, 6, 13 and average 30/4=7.5. Answer B. D’s arrival at 6 does not preempt C, whose remaining time is 1.

2. Explanation and checks. For SRTF, at time 2 A has 8 left and B needs 6, so B preempts A. At time 4 B has 4 left and C needs 3, so C preempts B. At time 6 C needs only 1 more, so D does not preempt it. In nonpreemptive SJF, A cannot be displaced after starting at time 0; when it finishes at 10 all others are ready and C is shortest. These decisions explain the difference in the two timelines.

Original paper, page 25 · Answer key