Interview Prep Zoneby CuriouserLabs

Question 2 of 5 · senior level

Compare the classic scheduling algorithms — FCFS, SJF, Round Robin, priority, MLFQ. What survives into real systems?

🎤 Say this first

FCFS is trivially fair-by-arrival but suffers the convoy effect (one long job queues everyone). SJF/SRTF minimizes average waiting time — provably optimal — but needs future knowledge and starves long jobs. Round Robin adds preemption by quantum: great responsiveness, bounded delay, but pure RR treats all tasks equally. Priority scheduling expresses importance but invites starvation (fix: aging). MLFQ combines them: multiple queues by priority, new/I/O-bound tasks stay high, CPU hogs sink — approximating SJF without future knowledge by using the past as prediction. Real schedulers are MLFQ's descendants or fair-share designs (CFS).

The full picture

🎬 Round Robin scheduling with I/O blocking

1 / 5
Ready queue (FIFO)P1P2P3CPUWaiting on I/O 💾Preemption + blocking are the two ways a process leaves the CPU — every scheduler question reduces to these moves.

Round Robin with a fixed time quantum. Three processes wait in the ready queue; the scheduler gives each a slice of CPU in turn.

Round Robin with a twist: watch what happens when a process blocks on I/O.
AlgorithmOptimizesFatal flawModern echo
FCFSsimplicityconvoy effectFIFO queues inside same-priority levels
SJF / SRTFavg waiting time (optimal)needs the future; starves long jobsMLFQ approximates it from history
Round Robinresponse time, fairnessquantum tuning; ignores importancethe base rotation everywhere
Priority (+aging)importancestarvation without agingnice values, cgroup weights
MLFQinteractivity + throughputgameable; tuning knobsWindows scheduler lineage

🔄 Likely follow-up questions

  • Design a quantum: what breaks at 1ms vs 100ms?
  • How can a process game MLFQ, and how do schedulers defend?
  • Map these algorithms onto a message-queue consumer-group design.