Round Robin Scheduling : Explained

Abstract

It is designed especially for time-sharing systems. It is similar to FCFS scheduling, but preemption is added to switch between the processes. Each process is assigned a fixed time quantum in a cyclic way.

Scope

This article explains round-robin scheduling in detail.

Definition

It is the most popular scheduling algorithm. In round-robin scheduling, we maintain a time quantum and we maintain the ready queue as a circular queue. We pick processes one by one in a circular manner and assign them for example 2 units of time, which is quantum. If the process is going to take less than 2 units of time then that process finishes and immediately releases the CPU. If the process needs 2 units or more than 2 units, we give it 2 units and then preempt it and move to the next process. This algorithm is of preemptive nature. 

Let’s understand it with an example :

PROCESSARRIVAL TIMEBURST TIME
P003
P111
P215

Each process runs for 2 units of time, followed by the next process. The whole process runs in a circular manner.

PROCESSARRIVAL TIMEBURST TIME
P003     1
P111    0
P215    3

P0 is scheduled at t = 0 and it runs for 2 units of time because the time quantum is 2. Only P0 is there in the circular queue. The circular queue can be understood as a circular linked list where the link of the last node points to the first node. After 2 units of time, more processes are added to the circular queue. P1 and P2 arrive at the same time. After P0 completes its units of time then P1 is scheduled. P1 takes only 1 unit out of 2 units of time. Then P2 runs for 2 units of time. After this P0 takes the processor and runs its remaining time. Now, P2 is the only process left and it runs for its remaining time. 

Gnatt chart

PROCESSARRIVAL TIMEBURST TIME COMPLETION TIMETURN AROUND TIMEWAITING TIME
P0      03630
P1      11211
P2      15832

Some important points:

  • The average waiting time is higher because the process is preempted after a particular time quantum. 
  • The best part about the round-robin scheduling is the good response time. In this, every process is assigned after a certain quantum number according to the number of processes in the ready queue. So every process gets some response time. 
  • Unlike priority scheduling and FCFS(First-Come-First-Serve) scheduling, the problem of starvation does not arise in round-robin scheduling. Every process gets a fixed quantum and has a good response time.
  • This algorithm is very sensitive to time quantum. If the time quantum is really low, the context switches are very frequent and if the quantum is high then it becomes FCFS.

Summary:

In round-robin scheduling, each process is assigned a fixed quantum and it runs in a circular manner. The ready queue is treated as a circular queue. It is a preemptive algorithm and is specially designed for time-sharing systems.

Special thanks to Ami Jangid for contributing to this article on takeUforward. If you also wish to share your knowledge with the takeUforward fam, please check out this article