Header Ads Widget

Round Robin Scheduling

The round robin scheduling algorithm is designed especially for time sharing systems. It is similar to FCFS, but preemption is added to enable the system to switch between processes. A small unit of time called time quantum is defined. 

In this scheduling algorithm, the ready queue is treated as circular queue. New processes are added to the tail of the ready queue. The CPU scheduler picks the first process from the front of ready queue, sets a time to interrupt after one time quantum and dispatches the process. If the burst time of process is less than time quantum, then on the completion of burst time this process itself releases the CPU. When burst time is longer than time quantum, then after one time quantum process is preempted and  put at the tail of the ready queue. After that, a new process is taken from the front of ready queue. Context switching is used to save states of preempted process. 

Example :

 Consider following set of processes that arrive at 0 ms.

round robin scheduling
If we use time quantum of 5 ms then -
(1) Calculate average waiting time using R-R scheduling.
(2) Calculate average turn around time.

Solution :

Gantt Chart
gantt chart round robin scheduling
(1) Waiting time for P1 = 0 + (15-5) + (24-20) = 10+4 = 14 ms
      Waiting time for P2 = (5-0) = 5 ms
      Waiting time for P3 = (10-0) + (20-15) = 10+5 =15 ms
       Average waiting time = [(14+5+15)/3] ms =  11.33 ms

(2) Turn around time for P1= (32-0) =32 ms
      Turn around time for P2 = (10-0) = 10 ms
      Turn around time for P3 = (24-0) = 24 ms
      Average turn around time = [(32+10+24) /3] ms = 22 ms

Advantages of  Round-Robin Scheduling :

  • All processes get a fair allocation of CPU.
  • It deals with all process without any priority.
  • It does not face the issue of starvation.

Disadvantages of Round-Robin Scheduling :

  • This method spends more time on context switches.
  • priorities can not be set for more important processes.
  • It increases the average waiting time.

Post a Comment

0 Comments