AI InterviewSearch…Search problems, topics, or pages…Ctrl KGet started
Hardschedulingsrtfpreemption

~180s

Preemptive shortest remaining time first

Four processes arrive at different times:

ProcessArrival timeBurst time
P108
P214
P329
P435

Under shortest-remaining-time-first (preemptive SJF) scheduling, what is the average waiting time?

Show the answer and the worked solution

Correct answer: C.

6.50

Worked solution

  1. P1 starts at 0. At time 1, P2 arrives needing 4 while P1 still needs 7, so P2 preempts and runs to completion at time 5.
  2. P3 arrives at 2 needing 9 and P4 at 3 needing 5; neither beats P2's remaining time, so neither preempts.
  3. At time 5 the remaining times are P1 = 7, P3 = 9, P4 = 5, so P4 runs from 5 to 10, then P1 from 10 to 17, then P3 from 17 to 26.
  4. Waiting time is turnaround minus burst: P1 = 17 − 8 = 9, P2 = 4 − 4 = 0, P3 = 24 − 9 = 15, P4 = 7 − 5 = 2.
  5. The total is 26, so the average is 26 / 4 = 6.50 units.

Answer: 6.50.

The idea

Compute turnaround as completion minus arrival, then subtract the burst — that route survives any number of preemptions, whereas trying to add up idle intervals by hand rarely does.

Shortcut. Total waiting = sum of completions − sum of arrivals − sum of bursts = (5 + 10 + 17 + 26) − 6 − 26 = 26, so the average is 6.50.

Common trap. 7.75 runs the jobs without preemption: P1 keeps the CPU to 8, then P2, P4 and P3 follow, giving waits 0, 7, 9 and 15, which total 31.

Preemptive shortest remaining time first — Aptitude Question

Preemptive shortest remaining time first: Four processes arrive at different times: | Process | Arrival time |… Answer and worked solution on CodeKairo.

Question

Four processes arrive at different times:

ProcessArrival timeBurst time
P108
P214
P329
P435

Under shortest-remaining-time-first (preemptive SJF) scheduling, what is the average waiting time?

Options

  1. 4.50
  2. 5.50
  3. 6.50
  4. 7.75
Show the answer and the worked solution

Correct answer: C. 6.50

Worked solution

  1. P1 starts at 0. At time 1, P2 arrives needing 4 while P1 still needs 7, so P2 preempts and runs to completion at time 5.
  2. P3 arrives at 2 needing 9 and P4 at 3 needing 5; neither beats P2's remaining time, so neither preempts.
  3. At time 5 the remaining times are P1 = 7, P3 = 9, P4 = 5, so P4 runs from 5 to 10, then P1 from 10 to 17, then P3 from 17 to 26.
  4. Waiting time is turnaround minus burst: P1 = 17 − 8 = 9, P2 = 4 − 4 = 0, P3 = 24 − 9 = 15, P4 = 7 − 5 = 2.
  5. The total is 26, so the average is 26 / 4 = 6.50 units.

Answer: 6.50.

The idea

Compute turnaround as completion minus arrival, then subtract the burst — that route survives any number of preemptions, whereas trying to add up idle intervals by hand rarely does.

Shortcut. Total waiting = sum of completions − sum of arrivals − sum of bursts = (5 + 10 + 17 + 26) − 6 − 26 = 26, so the average is 6.50.

Common trap. 7.75 runs the jobs without preemption: P1 keeps the CPU to 8, then P2, P4 and P3 follow, giving waits 0, 7, 9 and 15, which total 31.

All OS, DBMS & Networks questions · placement mock tests