# 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.

### 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 :

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

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

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.