Skip to content
UniCircle
MediumNumericalCPU scheduling

Average waiting time under FCFS and SJF scheduling

Question OS-105

Four processes arrive at time 0 in the order P1, P2, P3, P4 with CPU burst times 5, 9, 2 and 4 ms respectively. Compute the average waiting time and average turnaround time under FCFS and under non-preemptive SJF. Which is better and why?

Show hints

Waiting time = start time − arrival time when each process runs in one go.

Show the explanation

Worked answer. All arrivals are at t = 0 and each process runs to completion once started, so waiting time = start time, and turnaround = completion time.

FCFS (order P1, P2, P3, P4)

ProcessStartFinishWaitingTurnaround
P10505
P2514514
P314161416
P416201620
  • Total waiting = 0 + 5 + 14 + 16 = 35 → average 8.75 ms
  • Total turnaround = 5 + 14 + 16 + 20 = 55 → average 13.75 ms

Non-preemptive SJF (order P3, P4, P1, P2 by burst 2, 4, 5, 9)

ProcessStartFinishWaitingTurnaround
P30202
P42626
P1611611
P211201120
  • Total waiting = 0 + 2 + 6 + 11 = 19 → average 4.75 ms
  • Total turnaround = 2 + 6 + 11 + 20 = 39 → average 9.75 ms

Sanity check: turnaround = waiting + burst, and the bursts sum to 20, so 35 + 20 = 55 and 19 + 20 = 39. Both match.

Why SJF wins: running short jobs first means fewer processes are kept waiting behind a long job (the "convoy effect" in FCFS, here P3 and P4 waiting behind P2). For a set of jobs that are all available together, SJF gives the minimum possible average waiting time.

Follow-up: "What is the catch with SJF?" The OS cannot know future burst lengths, so it estimates them (often by exponential averaging of past bursts), and long jobs can starve. The preemptive version is Shortest Remaining Time First (SRTF).

Original UniCircle question. Last reviewed 28 Oct 2026.