Round Robin
Everyone gets a turn. The scheduler behind every interactive system you use.
Skip to the animationRound Robin gives each process a fixed time slice — the quantum — in circular order, preempting anything that overruns and sending it to the back of the queue. It is FCFS with a timer, and it is the scheduler behind every interactive system you use.
How it works
- 1The ready queue is FIFO. Dispatch the process at the front and start a timer set to one quantum.
- 2If the process finishes or blocks before the timer fires, it leaves and the next process is dispatched immediately.
- 3If the timer fires first, the interrupt preempts the process, its context is saved, and it goes to the back of the queue.
- 4Repeat. Every process gets the CPU at regular intervals, forever, until it is done.
With n processes and quantum q, nobody waits more than (n − 1) × q before their next turn. That bounded response time is the guarantee Round Robin exists to give — and no other algorithm here provides it.
Choosing the quantum
The quantum is the only tuning knob, and both extremes fail:
- Too large and every process finishes inside its slice — the timer never fires and Round Robin degenerates into plain FCFS, convoy effect and all.
- Too small and the CPU spends its life context switching. If a switch costs 10 µs and the quantum is 100 µs, you are burning 10% of the machine on overhead alone.
The rule of thumb is that the quantum should be large compared to a context switch, and long enough that roughly 80% of CPU bursts finish within it. Real systems land at 10–100 ms against context switches measured in microseconds.
Turnaround time is not monotonic in the quantum — increasing it does not steadily improve average turnaround. The best value has to be found for the workload, not derived.
The vocabulary
- Arrival time
- When the process shows up in the ready queue. The scheduler cannot pick something that has not arrived yet — that single rule decides most exam answers.
- Burst time
- How long this process needs the CPU for, uninterrupted, before it would block or finish. Also called CPU burst.
- Ready queue
- Every process that could run right now but does not have the CPU. Scheduling is entirely the question of who gets pulled out of here next.
- Preemptive vs non-preemptive
- A non-preemptive scheduler cannot take the CPU back — once dispatched, a process runs until it blocks or finishes. A preemptive one can interrupt it mid-burst.
- Context switch
- Saving one process's registers and loading another's. Pure overhead: real work stops while it happens, typically a few microseconds.
- Starvation
- A process that stays runnable but never gets picked, because something more attractive keeps arriving. The classic fix is ageing — slowly raising the priority of anything that has waited a long time.
What you get and what you pay
On the same three processes that made FCFS look terrible (bursts 24, 3, 3, all arriving at t = 0), with a quantum of 4:
| Scheduler | Average waiting | Average turnaround |
|---|---|---|
| FCFS | 17.00 | 27.00 |
| Round Robin (q = 4) | 5.67 | 15.67 |
| SJF | 3.00 | 13.00 |
Round Robin is nowhere near SJF's average — and it never will be, because it deliberately ignores burst length. What it buys instead is that P2 and P3 start running at t = 4 and t = 7 rather than t = 24, and that no process can ever starve. In an interactive system that trade is not close.
The numbers you will be asked for
- Turnaround time
completion − arrival
Total time the process spent in the system, from the moment it arrived to the moment it finished.
- Waiting time
turnaround − burst
The part of that which was pure waiting. It is the only part a scheduler can actually change — the burst is fixed work.
- Response time
first run − arrival
How long until the process gets the CPU for the first time. This is what an interactive user actually feels.
- Throughput
processes ÷ total time
How much work the machine completes per unit of time.
Advantages and disadvantages
Advantages
- No starvation ever — every process is guaranteed the CPU within (n − 1) × q.
- Excellent, predictable response time, which is what interactive users actually feel.
- Genuinely fair: it needs no knowledge of burst lengths or priorities.
- Simple to implement — a FIFO queue plus a timer interrupt.
Disadvantages
- Higher average turnaround time than SJF, because long jobs are chopped up.
- Every quantum expiry is a context switch, so overhead scales with how small q is.
- Performance hinges entirely on choosing q well, and the best q is workload-dependent.
- Treats all processes as equally important, so it cannot express urgency on its own.
Watch it work
Check yourself
question 1 / 4
One question at a time. Pick an answer to see why it is right or wrong, then move on — there is no score to keep and nothing is saved.