Round Robin Scheduling – CPU Scheduling

By | September 21, 2021

Round Robin Scheduling – CPU Scheduling

  • Round robin scheduling is similar to FCES tut preemption in added to switch between processes.
  • In RR scheduling, processes are dispatched in FIFO but are given a small amount of CPU time. This small amount of time is known as time quantum or time slice A time quantum is generally from 10 to 100 milliseconds.
  • If a process does not complete before its time slice expires, the CPU is preempted and is given to the next waiting process in ready queue.
  • The preempted process in then placed at the tail of the ready queue.
  • If a process is completed before its time slice expires, the process itself releases the CPU. The scheduler then proceeds to the next process in ready queue.
  • Whenever any new process arrives in the system it is added at the tail of the ready queue.
  • Round-robin scheduling is effective in timesharing environments in which the system needs to guarantee reasonable response time for interactive users.
  • In this environment the preemption overhead is kept low by efficient context switching mechanisms and by providing adequate memory for the process to reside in main storage at the same time.

Round Robin Scheduling - CPU Scheduling

  • Round robin scheduling is always preemptive as no process is allocated the CPU for more than one time quantum in a row. If a process CPU burst exceeds one time quantum then that process is preempted and is put back at the tail of ready queue.

The performance of round robin scheduling algorithm depends upon several factors. These are :

1. Size of time quantum or slice

  • If the size of time slice is considerably larger then this algorithm becomes same as FC algorithm and thus performance degrades.
  • If the size of time slice is very small than the number of context switches increases a CPU will be busy in switching itself from one process to another rather than performing calculations.
  • Thus, the time quantum should not be very large and also should not be too small achieve good system performance.

2. Context Switching Overhead

  • Context switching is performed frequently in round robin scheduling as compared to the FCFS or SJF scheduling.
  • Context switch in round robin scheduling should be planned in such a way that it takes very less time.
  • In other words, the ratio between the context switching time and the calculation or execution time should be low.

Advantage of Round Robin

  1. It is fair scheduling algorithm as every process gets an equal share of the CPU.
  2. Overhead on processor is low.
  3. It provides good response time for short processes.

Disadvantages of Round Robin

  1. If the time quantum is too short, it increases the overhead and lowers the CPU efficiency on the other hand if it is too long, it results in poor response to shot processes. So care must be taken while choosing quantum size.

Example of Round-robin Scheduling

Let there be three processes P1, P2 and P3. Their CPU burst time is mentioned in the table below. The time quantum is of 2 milliseconds.

 

Process Burst Time
P1 10
P2 5
P3 2

Using RR scheduling, these three processes are scheduled in the following Gantt Chart:

 

Example of Round-robin Scheduling

Waiting time for P1 = 0 + (6-2) + (10-8) +(13-12)

=4 +2+1 =7 milliseconds 

Waiting time for P2 = 2+ (8 – 4) + (12-10)

=2 + 4 +2 = 8 milliseconds

Waiting time for P3 = 4 milliseconds

 Average waiting time = (7+8+4)/3 = 19/3 = 6.33 milliseconds 

Leave a Reply

Your email address will not be published. Required fields are marked *