Implementing a Round Robin Scheduling Algorithm in C++ programming language with a Gantt chart and arrival time. As we all know the Round Robin CPU Scheduling Algorithm, so we have to Write a Program code In C++ language to check how it performs all the operations. We are also going to discuss the Turn around time, burst time and execution time. In this article, you will get all the knowledge about the Round-robin. How it's works and the pro and cons.
We can Understand Round Robin Scheduling Algorithm by taking an example Suppose there is 4 process. and each process comes at the same time so based on FIFO(First in First Out) scheduler keep all process in Ready Queue and forgiven time Slice each process will be executed until all process finish. Let's take an example and try to understand How Round Robin Works.
Round Robin Example
Quantum = 4
Now Schedular keeps all process in Ready Queue and based on FIFO(First in First Out) send the first process for execution.
P1 P2 P3 P4 P1 P3 P4 P4
0 4 7 11 12 16 20 21
Average waiting time = 10.75
Average turn around time = 17
What is Round Robin Scheduling Algorithm?.
Round Robin is a primitive Scheduling Algorithm and most important and commonly used scheduling algorithm for CPU. In Round Robin Scheduling Algorithm each process has its own execution time that is called "Quantum".
After Quantum time next process start executes for given Quantum time and so on once a cycle complete again process execution start from first, process and repeat the process again and again and for saving a current state of process Context switching is used.
- -Round Robin is a primitive Scheduling Algorithm.
- -Round Robin follow FIFO(First in First Out) Principle.
- -For executing each process in Round Robin Time cluster or time Slice provides, so a process can execute for a particularly given amount of time, the given time is called Quantum.
- -After Quantum time for saving a state of each process Context switching is used.
- -Round Robin is Great to use for fully Utilization of a CPU and Multitasking.
- -Scheduler always needs to keep ready next process ready in ready Queue or Queue for execution in CPU so we can say that scheduler play an important role in the round-robin.
- -After Quantum Time for each process, the same step repeats again and again.
How to Calculate Turn Around Time?.
Turn Around Time = Completion Time – Arrival Time, With the help of this formula, we can calculate a Turn Around Time of all process in Queue.
How to Calculate Waiting Time?.
Waiting Time = Turn Around Time – Burst Time, This formula is used for calculating the waiting time for the rest of the process.