Tutorial Playlist
47 Lessons1. Introduction to Operating System
2. Types of Operating Systems
3. Linux Operating System
4. An Introduction To Unix Operating System
5. Ubuntu Operating System
6. MS DOS Operating System
7. Mobile Operating System
8. Understanding Functions of Operating System
9. Components of Operating System
10. Understanding the Kernel in Operating Systems
11. Structure of Operating System
12. Process in Operating System
13. What is Bios
14. What is Booting in Computer
15. What is Interrupt in Operating System?
16. Process Control Block in Operating Systems
17. Threads in Operating System
18. Process Synchronization in OS
19. Critical Section in OS
20. Semaphore in Operating System
21. Deadlock in Operating System
22. Deadlock Prevention in OS
23. Paging in Operating System
24. Segmentation in Operating System
25. Virtual Memory in Operating System
26. File System in Operating Systems
27. Page Table in OS
28. Round Robin Scheduling in Operating System
Now Reading
29. Shortest Job First Scheduling Algorithm
30. Priority Scheduling in OS
31. Page Replacement Algorithms in Operating System
32. Race Condition in OS
33. Distributed Operating System
34. Navigating Contiguous Memory Allocation in Operating Systems
35. Fragmentation in Operating System
36. Banker’s Algorithm in OS
37. Context Switching in OS
38. First Come First Serve (FCFS) Scheduling Algorithm in Operating System
39. Understanding Inter Process Communication in OS
40. Multiprogramming Operating System
41. Python OS Module
42. Preemptive Priority Scheduling Algorithm
43. Resource Allocation Graph in OS
44. Scheduling Algorithms in OS
45. System Calls In Operating System
46. Thrashing in Operating Systems: A Deep Dive
47. Time Sharing Operating System
CPU scheduling ensures timely execution of processes on a computer's CPU, often referred to as the brain of the computer. It determines the order of process execution, allowing one process to use the CPU while others wait. This approach promotes efficiency and ensures smooth system performance.
Round-robin CPU scheduling is the most efficient scheduling algorithm. Mostly used in multitasking systems, this method has helped me run a system for years at its full capacity. Let me explain the process of Round Robin scheduling in OS to help you understand its application altogether.
The Round Robin scheduling algorithm is a process that allotts each task to a fixed period of time quantum to be executed. Time quantum is the time frame for which a task is allowed to run in a pre-emptive technique.
Processes that have remaining burst time after the expiration of their time quantum are returned to the ready state, awaiting their next opportunity for execution. This process, which operates on a first-come-first-serve (FIFO) basis, ensures that all processes are given fair access to the CPU and prevents starvation. It continues until a process terminates.
However, to understand the working of Round Robin algorithm, ensure that you know all about what an operating system is and what it does.
Some features of this OS scheduling are as follows:
This scheduling algorithm ensures balanced resource usage to prevent errors and other issues. A real life example of Round Robin scheduling can be seen in offices. Let’s say, you are in a business meeting that uses Round Robin scheduling. In such a setting, every attendee takes turns in presenting their ideas.
To implement the Round Robin CPU scheduling, processes are placed in a ready queue. Each process has a burst time compared against the CPU's time quantum. If the burst time is equal to or less than the time slice, the process is executed for the burst time. If it exceeds the time slice, it runs until the time slice ends. If not completed, the process returns to a ready state.
Check out the Round Robin process scheduling algorithm above to understand the process better.
Round-robin is a very old and popularly used CPU scheduling method. Some of its advantages are as follows:
Some disadvantages of this scheduling algorithm are as follows:
Here’s a good Round Robin scheduling example.
Let’s say, you and I are up against each other in a tennis tournament. With this scheduling method, all the matches in the tournament are allocated time. How you and I perform during that time slice we have, will determine who moves forward and who loses.
With this, we can say that the Round Robin algorithm performance largely depends on the quantum size. If the quantum size is too small, there will be too many context switches which will waste CPU time.
On the contrary, if the quantum size is too large, the algorithm will reduce the fairness and responsiveness of the system. Hence, the quantum time should be based on the requirements and characteristics of the tasks and system.
It should neither be too small nor too large.
Let us check out the Round Robin scheduling algorithm with example:
There are six processes in a system. Calculate the turn-around times as well as the average waiting time for algorithm having a 3 units time quantum.
The arrival time and burst time of the processes are given below:
Process name | Arrival time | Burst time |
P1 | 0 | 4 |
P2 | 1 | 5 |
P3 | 2 | 2 |
P4 | 3 | 1 |
P5 | 4 | 4 |
P6 | 5 | 3 |
The process P1 is going to be in the queue at first. It is going to be run for time frame 3 units.
P1 |
4 |
As the first process is being executed, P2, P3, and P4 are added in the queue. At the end of this process, P1 has 1 unit left to be executed, hence it is put in the queue.
P2 | P3 | P4 | P1 |
5 | 2 | 1 | 1 |
As P2 is being executed, P5 and P6 have arrived at the queue. As P2 is not completely executed, it is put in queue.
P3 | P4 | P1 | P5 | P6 | P2 |
2 | 1 | 1 | 4 | 3 | 2 |
Processes P3 as well as P4 are completed. However, the remaining P5 has burst time left, which is why it is added at the back of the line-up.
P1 | P6 | P2 | P5 |
1 | 3 | 2 | 1 |
All the processes are executed except P5. it is the only process left with a burst time of 1 unit.
P5 |
1 |
The GANTT chart of the above process is:
P1 | P2 | P3 | P4 | P1 | P5 | P6 | P2 | P5 |
0 3 6 8 9 10 13 16 18 19
To find out the turn-around time and the waiting time of the above process, we can create the following table.
Process name | Arrival time | Burst time | Turn-around time (completion time - arrival time) | Waiting time (turn-around time - burst time) |
P1 | 0 | 4 | 10 | 6 |
P2 | 1 | 5 | 17 | 12 |
P3 | 2 | 2 | 6 | 4 |
P4 | 3 | 1 | 6 | 5 |
P5 | 4 | 4 | 15 | 11 |
P6 | 5 | 3 | 11 | 8 |
Average waiting time = (6+12+4+5+11+8)/6 = 46/6 = 7.66
Calculate Round Robin scheduling and the average waiting time for the processes given below:
Process name | Arrival time | Burst time |
P1 | 0 | 7 |
P2 | 1 | 4 |
P3 | 2 | 5 |
P4 | 3 | 8 |
The time quantum value is 4.
At first the process P1 is going to be executed. It has a burst time of 7.
P1 |
7 |
As the first process is being executed through four units, the remaining processes, P2, P3, and P4 are added to the queue. P1 is not completely executed and hence it is added to the back of the queue.
P2 | P3 | P4 | P1 |
4 | 5 | 8 | 3 |
P2 is completed in this step, but P3 and P4 are not, which is why it is added to the back of the queue.
P1 | P3 | P4 |
3 | 1 | 4 |
All the processes are executed, apart from P4. It is again added to the queue.
P4 |
4 |
The GANTT chart of this scheduled algorithm is as follows:
P1 | P2 | P3 | P4 | P1 | P3 | P4 |
0 4 8 12 16 19 20 24
Process name | Arrival time | Burst time | Turn-around time (completion time - arrival time) | Waiting time (turn-around time - burst time) |
P1 | 0 | 7 | 19 | 12 |
P2 | 1 | 4 | 7 | 3 |
P3 | 2 | 5 | 18 | 13 |
P4 | 3 | 8 | 21 | 13 |
Average wait time: (12+3+13+13)/4 = 41/4 = 10.25
Know about the functions of an operating system to understand the implications of Round Robin scheduling algorithm.
Both of these are scheduling algorithms, however, there are some major differences between them.
Round Robin | Shortest Job First |
It executes processes depending upon the denied time quantum | It executes processes depending upon the ascending order of their burst times. |
The average waiting time is the minimum for a given set of processes. | The average waiting time is very small depending upon the time quantum. |
It is difficult to know the length of the next CPU burst or request. | It is quite easy to implement. |
Long processes might not get executed. The system might only execute the short ones. | Every process is executed in fixed time intervals. |
The Round Robin scheduling in operating systems stands out for its simplicity and fairness. In my experience, it is a great way of increasing the efficiency of your system. The balanced approach that this process provides, is necessary for multitasking systems.
The Round Robin CPU scheduling algorithm is needed in many fields. If you want you expand your career, enrolling in a certified course can be a great choice. Check out the courses upGrad is offering. These courses are taught by experienced professionals and will make you ready for the market.
In this CPU scheduling method, each process is given a fixed time period, called a quantum, for execution. If the process doesn't finish within this time, it's returned to the scheduling queue for later processing.
In round robin scheduling, processes are executed in a circular manner. For example, process A is executed for a fixed time, followed by process B, and so forth until completion.
It's the structure used to implement round robin scheduling, involving maintaining a queue of processes and cycling through them, allocating each a fixed time slice.
The basis of this principle is that every task is arranged cyclically and all of them are executed turn-by-turn. Hence the name Round Robin.
It provides fair allocation of CPU time among processes, prevents starvation, and ensures responsiveness, especially in time-sharing systems.
Round-robing CPU scheduling is one of the most fair OS scheduling methods. Here each process is allocated a fixed amount of time. Once the time expires, the process moves back to the end of the queue. This ensures that every process is executed by the CPU.
Every process is assigned a specific time interval (quantum) for execution. These processes are arranged in a queue, and if a process doesn't complete its task within the allotted time, it's interrupted and returned to the queue.
Round robin ensures fairness and prevents starvation by giving each process a chance to execute, whereas SJF may lead to longer waiting times for processes with longer burst times, potentially causing starvation for shorter processes.
The best CPU scheduling algorithm varies depending on the system's requirements. It's not universally optimal for all scenarios and is influenced by factors such as system load, process characteristics, and system goals.
Yes, round robin is a CPU scheduling algorithm commonly used in operating systems to allocate CPU time among multiple processes.
Ankit Mittal
Working as an Senior Software Engineer at upGrad, with proven experience across various industries.
Talk to our experts. We’re available 24/7.
Indian Nationals
1800 210 2020
Foreign Nationals
+918045604032
upGrad does not grant credit; credits are granted, accepted or transferred at the sole discretion of the relevant educational institution offering the diploma or degree. We advise you to enquire further regarding the suitability of this program for your academic, professional requirements and job prospects before enrolling. upGrad does not make any representations regarding the recognition or equivalence of the credits or credentials awarded, unless otherwise expressly stated. Success depends on individual qualifications, experience, and efforts in seeking employment.
upGrad does not grant credit; credits are granted, accepted or transferred at the sole discretion of the relevant educational institution offering the diploma or degree. We advise you to enquire further regarding the suitability of this program for your academic, professional requirements and job prospects before enr...