Round Robin is a CPU scheduling algorithm where each process is assigned a fixed time slot in a cyclic way.
- It is simple, easy to implement, and starvation-free as all processes get fair share of CPU.
- One of the most commonly used technique in CPU scheduling as a core.
- It is preemptive as processes are assigned CPU only for a fixed slice of time at most.
- The disadvantage of it is more overhead of context switching.
|1.||There is fairness since every process gets equal share of CPU.||There is Larger waiting time and Response time.|
|2.||The newly created process is added to end of ready queue.||There is Low throughput.|
|3.||A round-robin scheduler generally employs time-sharing, giving each job a time slot or quantum.||There is Context Switches.|
|4.||While performing a round-robin scheduling,a particular time quantum is alloted to different jobs.||Gantt chart seems to come too big (if quantum time is less for scheduling.For Example:1 ms for big scheduling.)|
|5.||Each process get a chance to reschedule after a particular quantum time in this scheduling.||Time consuming scheduling for small quantums .|
How to compute below times in Round Robin using a program?
- Completion Time: Time at which process completes its execution.
- Turn Around Time: Time Difference between completion time and arrival time. Turn Around Time = Completion Time – Arrival Time
- Waiting Time(W.T): Time Difference between turn around time and burst time.
Waiting Time = Turn Around Time – Burst Time
In this post, we have assumed arrival times as 0, so turn around and completion times are same.
The tricky part is to compute waiting times. Once waiting times are computed, turn around times can be quickly computed.
Steps to find waiting times of all processes:
1- Create an array rem_bt to keep track of remaining burst time of processes. This array is initially a copy of bt (burst times array) 2- Create another array wt to store waiting times of processes. Initialize this array as 0. 3- Initialize time : t = 0 4- Keep traversing the all processes while all processes are not done. Do following for i'th process if it is not done yet. a- If rem_bt[i] > quantum (i) t = t + quantum (ii) bt_rem[i] -= quantum; c- Else // Last cycle for this process (i) t = t + bt_rem[i]; (ii) wt[i] = t - bt[i] (ii) bt_rem[i] = 0; // This process is over
Once we have waiting times, we can compute turn around time tat[i] of a process as sum of waiting and burst times, i.e., wt[i] + bt[i]
Below is implementation of above steps.
Processes Burst time Waiting time Turn around time 1 10 13 23 2 5 10 15 3 8 13 21 Average waiting time = 12 Average turn around time = 19.6667
This article is contributed by Sahil Chhabra. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Selfish Round Robin CPU Scheduling
- Round Robin Scheduling with different arrival times
- Completion time of a given process in round robin
- Program for Priority CPU Scheduling | Set 1
- Program for FCFS CPU Scheduling | Set 1
- Program for Shortest Job First (SJF) scheduling | Set 2 (Preemptive)
- Program for Preemptive Priority CPU Scheduling
- Program for Shortest Job First (or SJF) CPU Scheduling | Set 1 (Non- preemptive)
- Program for SSTF disk scheduling algorithm
- Multilevel Feedback Queue Scheduling (MLFQ) CPU Scheduling
- Program for FCFS CPU Scheduling | Set 2 (Processes with different arrival times)
- Longest Remaining Time First (LRTF) CPU Scheduling Program
- LOOK Disk Scheduling Algorithm
- Disk Scheduling Algorithms
- CPU Scheduling in Operating Systems