Round robin is a scheduling algorithm where a fixed amount of execution time called a time slice is chosen and then assigned to each process, continually cycling through all of these processes until they are completed. Processes that do not finish during their assigned time are rescheduled to allow all other processes an opportunity to run first. This can be seen in the example to the right where each process is given a maximum of 2 seconds to run before the next process is handed to the scheduler.

Overall this algorithm provides a balanced throughput between first come, first served and shortest job first due to treating each process equally and giving each process an opportunity to run. On average, longer jobs are completed faster than in shortest job first, and shorter jobs are completed faster than in first come, first served.

Starvation also can not occur as there is no preference for a certain subset of processes. Each process will be run occasionally as the scheduler makes its rounds. This leads to lower latency and response times as they only correspond to the number of processes running and the time slice allotted to each process. However, this can cause high waiting times as, while each process can be run often, it may not necessarily complete quickly.

Deadlines are also largely ignored, making this algorithm not the best fit for real-time devices such as car safety systems that need to guarantee the deployment of an airbag by some set time. The greatest weakness of this algorithm is that due to the context switching required at every time slice, round robin has extensive scheduling overhead that steals CPU utilization away from all of the other processes on the system.


In this example animation of Round Robin to the right, each process is run for the given time slice of 2 seconds.

P2 executes first for 2 seconds, but as it has a completion time of 5 seconds, it does not finish. Afterwards, P3 runs for 0.5 seconds, completing the time slice early. P1 then executes for 2 seconds and finishes while P5 is added to the Ready Queue.

P4 is the next to run for 1 second, completing the time slice early like P3. P2 is then run once more for 2 seconds, but again does not finish. The newly added P5 is subsequently given a chance to run for 2 seconds and completes before P2 is executed for the third and final time.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?