AlgoViz
← Back to trail

Round-Robin Scheduling

Medium+14 XP

Watch each process get a small time-slice and pass the CPU on — the fix for FCFS's convoy problem.

No visualization loaded.

Watch

i

Press Run to begin.

FCFS let one big job hog the CPU while everyone waited. Round-Robin fixes that: give each process a small fixed time-slice (a 'quantum'), then rotate to the next. Press Run and watch the same jobs take turns.

What's a 'quantum' / time-slice?

The small chunk of time each process is allowed to run before it MUST hand the CPU to the next one — here it's 2 ticks. When your slice is up, you go to the back of the line and wait for your next turn, even if you're not finished.

How is this different from FCFS?

FCFS runs each job start-to-finish before the next begins — so a long job blocks everyone. Round-Robin interrupts after each small slice and rotates, so short jobs finish quickly instead of waiting behind a big one. Compare the two Gantt charts — same jobs, very different waits.

Why is taking turns better?

Fairness and responsiveness. Everyone makes progress, and quick tasks feel snappy because they don't wait for slow ones. This is why your computer stays responsive even while a heavy program runs — that program only gets slices, not the whole CPU.

What if the quantum is too small or too big?

Too big, and it acts like FCFS (one job hogs the CPU). Too small, and the OS spends all its time context-switching (overhead) instead of doing work. The quantum is a dial the OS tunes for a good balance.

🧠Round-Robin gives every process a small time-slice, then rotates — so no job hogs the CPU and short tasks don't get stuck behind long ones. It trades a little switching overhead for fairness and responsiveness.
P1 runningP2 runningP3 running