How does the RR algorithm work?
In an operating system, some processes need to be executed. Processes are roughly a program that needs to be executed.
Since multiple processes need to be executed, the OS needs to prioritize and manage them efficiently. The process scheduler manages this. It decides which process should be carried out and when it should be done. The process scheduler helps utilize the resources effectively.
There are multiple algorithms used for this. Some of them are First Come First Serve(FCFS), Short Job First(SJF), Longest Job First(LJF), and Round Robin(RR) Algorithms.
This blog will discuss a little bit about the Round Robin Algorithm.
In the RR algorithm, there is a fixed time called quantum time for a process will execute. Once the quantum time is over, the process is put on queue. And the next process is run. This goes on in a cycle.
RR algorithm is a preemptive algorithm since it puts processes on hold before they may be completed. It is also referred to as the preemptive version of the FCFS algorithm.
It is one of the most commonly used algorithms in CPU. It is easy to implement. It also ensures the utilization of CPU resources efficiently. There is no starvation as well as a process does not have to wait for a long time to get the resources it wants to be executed.
However, there are some downsides to it as well. The most obvious one is that important tasks are not given priority. Also whenever the job runs a course time and it is put on a queue, a context switch happens. This adds to the execution time. Choosing the correct quantum time is also a difficult job.
It does result in higher turnaround time but it is the most efficient in a multitasking environment like in the operating system.
That's it for today!