How Round Robin works
Round Robin (RR) gives every process a turn of fixed length, called the time quantum or time slice. The ready queue is first in, first out. The process at the front runs for up to one quantum; if it still has work left when the slice ends, it goes to the back of the queue and the next process gets its turn.
Three situations decide most schedules. If a process finishes before its slice ends, it gives up the CPU at that moment, and the next process starts straight away with a full slice. If a slice ends and nobody else is waiting, the same process simply continues with a new slice; the timeline marks that boundary with a thin tick inside the bar. And a process that arrives in the middle of a slice joins the back of the queue at its arrival time, ahead of the process whose slice is still running.
One moment where sources differ is a new arrival at the exact instant a slice ends. Trace puts the new arrival in the queue first by default, then the process whose slice just ended. The "Ties at the same moment" switch reverses that, so you can match the convention your course uses. The Tie trap preset shows a case where the choice changes the answer.
The quantum shapes everything. A very large quantum means no process is ever cut off, and Round Robin turns into First Come First Served. A very small one gives every process a quick first turn, but in a real system each switch costs time, which Trace does not model. Do not expect average waiting time to move steadily as you change the quantum: for the example below it is 5.67 with a quantum of 4, 5.00 with 3, 6.33 with 2 and 17 with 24.
Worked example
Three processes arrive at time 0 with bursts 24, 3 and 3, and the quantum is 4. P1 runs first, uses its full slice and goes to the back. P2 and P3 each finish within their first slice, at 7 and 10.
Round Robin with a time quantum of 4. Order of execution: P1 0 to 4, P2 4 to 7, P3 7 to 10, P1 10 to 14, P1 14 to 18, P1 18 to 22, P1 22 to 26, P1 26 to 30.
| Process | Arrival | Burst | Finished | Turnaround | Waiting | Response |
|---|---|---|---|---|---|---|
| P1 | 0 | 24 | 30 | 30 | 6 | 0 |
| P2 | 0 | 3 | 7 | 7 | 4 | 4 |
| P3 | 0 | 3 | 10 | 10 | 7 | 7 |
| Average | 15.67 (47/3) | 5.67 (17/3) | 3.67 (11/3) |
From time 10, P1 is alone, so it keeps the CPU slice after slice until it finishes at 30. The average waiting time is (6 + 4 + 7) / 3 = 17/3, about 5.67, compared with 17 under FCFS for the same processes. Round Robin cuts the waiting time of the short jobs at the cost of finishing the long one later than it would otherwise.
Formulas
- Turnaround time
= finished - arrival - Waiting time
= turnaround - burst - Response time
= first run - arrival
Round Robin splits processes into many pieces, so add up waiting with the formula rather than by hand. P1 finishes at 30 with a burst of 24, so it waited 30 - 24 = 6 units, all of them between 4 and 10. Its response time is 0, because it started at once. Response time is where Round Robin usually shines, since every process gets the CPU within a bounded time after arriving.
Strengths and weaknesses
Strengths
- Fair: every ready process gets a turn, and nothing starves.
- Good response time, which suits interactive and time-sharing use.
- Needs no burst lengths or priorities, only the quantum.
Weaknesses
- Average turnaround is often higher than with SJF, because long and short jobs share the CPU.
- Performance depends heavily on choosing the quantum well.
- Frequent switches cost time in a real system.
Common exam mistakes
- Getting the queue order wrong on a tie. When an arrival and a slice end happen together, check which one your course puts first. Trace shows the rule in use and explains it in one line.
- Letting a finished process keep its slice. A process that needs only 1 unit of a 4-unit slice leaves after 1 unit; the next process starts immediately.
- Putting the preempted process back at the front. It goes to the back, behind everyone already waiting.
- Forgetting arrivals during a slice. They join the queue when they arrive, so they are ahead of the process whose slice is running when that slice ends.
- Counting slices instead of time. Waiting time is measured in time units, from arrival to completion, minus the burst.
Related
Spotted a mistake?
Round Robin answers depend on small rules, so please include the quantum, the tie setting and the processes, or simply the link from "Copy link".
Email: abdul at abmans dot com