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.
Solution :
(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.
0 Comments