On a system using non-preemptive scheduling, processes with expected run times…
20072007
On a system using non-preemptive scheduling, processes with expected run times of 5, 18, 9 and 12 are in the ready queue. In what order should they be run to minimize wait time?
Answer: B. 5, 9, 12, 18 — Concept. Under non-preemptive scheduling a process, once dispatched, keeps the CPU until it finishes, so the whole schedule is fixed the moment the serving…
- A.
5, 12, 9, 18
- B.
5, 9, 12, 18
- C.
12, 18, 9, 5
- D.
9, 12, 18, 5
Attempted by 537 students.
Show answer & explanation
Correct answer: B
Concept. Under non-preemptive scheduling a process, once dispatched, keeps the CPU until it finishes, so the whole schedule is fixed the moment the serving order is chosen. Each process therefore waits exactly as long as the total burst time of everything placed ahead of it, which means a job sitting in position i adds its own burst time to the waiting time of every job behind it. Writing the total waiting time as the sum of (n − i) × bi shows that the biggest multiplier falls on the job served earliest, so the smallest burst time must go first and the queue must be served in non-decreasing order of burst time — the Shortest Job First (SJF) rule. An exchange argument settles it: whenever two adjacent jobs are out of order, swapping them strictly lowers the total waiting time, so no permutation can beat the fully sorted one.
Note on the wording. The stem names no scheduling algorithm on purpose. It asks which serving order makes the waiting time smallest, and the argument above derives that order from first principles; the name Shortest Job First is the conclusion of the reasoning, not an assumption handed to you.
Application — schedule the four given run times.
Sort the four expected run times into non-decreasing order: 5, 9, 12, 18.
The 5-unit process starts at t = 0, so its waiting time is 0.
The 9-unit process starts at t = 0 + 5 = 5, so its waiting time is 5.
The 12-unit process starts at t = 5 + 9 = 14, so its waiting time is 14.
The 18-unit process starts at t = 14 + 12 = 26, so its waiting time is 26.
Total waiting time = 0 + 5 + 14 + 26 = 45 time units, so the average waiting time = 45 ÷ 4 = 11.25 time units.
Cross-check — every offered order, evaluated.
Serving order | Waiting times | Total | Average |
|---|---|---|---|
5, 9, 12, 18 | 0, 5, 14, 26 | 45 | 11.25 |
5, 12, 9, 18 | 0, 5, 17, 26 | 48 | 12 |
9, 12, 18, 5 | 0, 9, 21, 39 | 69 | 17.25 |
12, 18, 9, 5 | 0, 12, 30, 39 | 81 | 20.25 |
Every one of these schedules finishes at t = 44, because the CPU does the same 44 units of work in each case; only the waiting time moves. The ascending order 5, 9, 12, 18 produces the smallest total (45) and the smallest average (11.25), exactly as the SJF argument predicts, and it is the unique minimum.
A video solution is available for this question — log in and enroll to watch it.
Explore the full course: Iocl Engineers Officers Grade A Paper 2