Skip to content
We areTOP 1%

Compare FCFS and SJF scheduling. What is the convoy effect?

MediumConceptCPU Scheduling
Track your progress
First attempt
Re-solve after a few days
Final pass before interviews

Answer

First-Come, First-Served (FCFS) runs processes in the order they arrive, like a queue at a ticket counter. Shortest Job First (SJF) always picks the ready process with the smallest CPU burst.

  • FCFS is simple and never starves anyone, but it suffers from the convoy effect: short processes stuck behind one long process all wait, so the average waiting time becomes large.
  • SJF gives the minimum possible average waiting time for a set of processes, because running short jobs first reduces how long all the others wait.
  • SJF needs burst lengths in advance, which the OS cannot know, so it predicts the next burst from past ones by exponential averaging: τ(next) = α × t(last actual) + (1 − α) × τ(last prediction). Long jobs can also starve if short ones keep arriving.

Example: P1, P2 and P3 arrive at time 0 with bursts of 24, 3 and 3 ms.

OrderWaiting timesAverage
FCFS: P1, P2, P30, 24, 2751 / 3 = 17 ms
SJF: P2, P3, P10, 3, 69 / 3 = 3 ms

For prediction with α = 0.5, a previous prediction of 10 ms and an actual burst of 6 ms, the next prediction is 0.5 × 6 + 0.5 × 10 = 8 ms.

More in CPU Scheduling

Sign in to track your progress

Your checkboxes, streak and activity heatmap are saved to your account and sync across devices. It is free.
Sign in with email

New here? Create an account