There are number of CPU scheduling algorithms, all having different properties
thus making them appropriate for different conditions.
- Round robin scheduling algorithm or RR is commonly used in the time sharing
systems.
- This is the most appropriate scheduling algorithm for time sharing
operating systems.
- This algorithm shares many similarities with the FCFS
scheduling algorithm but there is an additional feature to it.
- This feature is
preemption in the context switch occurring between two processes.
- In this
algorithm a small unit of time is defined and is termed as the time slice or
the time quantum.
- These time slices or quantum range from 10ms to
100 ms.
- The ready queue in round robin scheduling is implemented in
a circular fashion.
How to implement Round Robin CPU scheduling algorithm
Now we shall see about the implementation of the round
robin scheduling:
- The ready queue is maintained as the FIFO
(first in first out) queue of the processes.
- Addition of new processes is made at the rear
end of the ready queue and selection of the process for execution by the
processor is made at the front end.
- The process first in the ready queue is thus
picked by the CPU scheduler. A timer is set that will interrupt the
processor when the time slice elapses. When this happens the process will
be dispatched.
- In some cases the CPU burst of some processes
may be less than the size of the time slice. If this is the case, the
process will be voluntarily released by the CPU. The scheduler will then
jump to the process next in the ready queue and fetch it for execution.
- While in other cases the CPU burst for some
processes might be higher than the size of the time slice. In this case
the timer set will send an interrupt to the processor, thus dispatching
the process and putting it at the rear end of the ready queue. The
scheduler will then jump to the next process in the queue.
- The
waiting time in round robin scheduling algorithm has been observed to be quite
long at an average rate.
- In this algorithm, not more than one time slice can be
allocated to any process under any conditions in a row.
- However, there is an
exception to this if there is only one process to be executed.
- If the CPU burst
is exceeded by the process, the process is put back at the tail of the queue
after preemption.
- Thus, we can call this algorithm as a preemptive algorithm
also.
- The size of the time quantum greatly affects the performance of the round
robin algorithm.
- If the size of the time quantum is kept too large then it
resembles the FCFS algorithm.
- On the other hand if the quantum is of too small
size, then this RR approach is called the processor sharing approach.
- An
illusion is created in which it seems every process has its own processor that
runs at the fraction of the speed of the actual processor.
- Further, the effect
of the context switching up on the performance of the RR scheduling algorithm.
- A
certain amount of time is utilized in switching from one process to another.
- In
this time the registers and the memory maps are loaded, a number of lists and
tables are updated; memory cache is flushed and reloaded etc.
- Lesser the size
of the time quantum, context switching will occur more number of times.
No comments:
Post a Comment