Skip to content
CurriculumLesson 12 · CPU Scheduling
Intermediate~16 min

Round Robin Scheduling

Round Robin is the scheduler that makes a single CPU feel interactive. Every process gets a small slice, then goes to the back of the line.

In plain English

Round robin gives everyone a turn, like dealing cards around a table.

By the end you will be able to

  • Trace the ready queue for Round Robin.
  • Run a full example with a time quantum.
  • Explain how quantum size changes response time and overhead.
  • Know why Round Robin is preemptive.
01

The queue mechanics

New arrivals join the ready queue. The scheduler takes the process at the front, runs it for at most one quantum, and then either completes it or sends it to the back of the queue. A process that blocks leaves the ready queue and returns when its event completes. The timer interrupt is what stops a process that uses its full quantum.

lesson-12.osOS
queue = arrivals at time 0;
while unfinished:
    p = queue.pop_front();
    run(p, min(quantum, p.remaining));
    enqueue arrivals during the slice;
    if p.remaining > 0: queue.push_back(p);
    else: complete(p);
02

Worked example

Processes P1 burst 5, P2 burst 3, P3 burst 1, all arriving at 0. Quantum = 2. Timeline: P1 0–2, P2 2–4, P3 4–5, P1 5–7, P2 7–8, P1 8–9. Completion: P1 9, P2 8, P3 5. Waiting: P1 4, P2 5, P3 4. Average waiting = 4.33. Notice that P3, the shortest job, still gets an early response.

lesson-12.osOS
| P1 | P2 |P3| P1 | P2 | P1 |
0    2    4  5    7    8    9
03

Choosing the quantum

If the quantum is very large, Round Robin degenerates into FCFS. If it is very small, the system spends too much time context switching and cache locality suffers. A good quantum is large enough to amortize the switch and small enough to keep response time acceptable. Round Robin is preemptive because the timer can stop a process at the end of its slice.

Watch it happen

Step through the worked example. Play it, pause it, or move one step at a time.

step-by-step

Step 1 of 6

t = 0 → 2 · P1

At t=0, P1 takes the CPU for a quantum of 2. It has 3 units left after this slice.

Gantt chartRound Robin · q=2
P1
P2
P3
P1
P2
P1
09
PIDArrBurstRemStateDone
P1053running—
P2033ready—
P3011ready—
ready at t=2:P1P2P3

Key takeaways

  • Round Robin gives each process a fixed time quantum.
  • The queue rotates after every slice.
  • A large quantum behaves like FCFS.
  • A tiny quantum wastes time on context switches.
  • Round Robin is preemptive and favors response time.

Common pitfalls

  • Forgetting to enqueue arrivals before re-queueing the current process.
  • Using a quantum larger than every burst and calling it Round Robin.
  • Ignoring the context-switch cost of a tiny quantum.

Kernel notes

  • Draw the ready queue after every slice.
  • Compute completion times from the timeline.
  • Explain the quantum trade-off in one sentence.

Quick check

0 / 2 answered

1. What happens when a process uses its full Round Robin quantum?

2. What does a very large Round Robin quantum approximate?