
Round Robin Scheduling algorithm
CPU scheduling algorithm
The Round Robin Scheduling algorithm has time quantum. Time quantum is fixed for the execution of each process. this name includes the equal share of something into their turns.
Characteristics of Round Robin Scheduling Algorithm
- It is a pre-emptive algorithm in nature that is added to the end of the queue.
- It is a hybrid model that is clock-driven.
- It is used more in traditional OS (Operating system).
- It is the very easiest and oldest algorithm.
- It is the real time-based algorithm that responds to the event in a specific time limit.
- The slice is varying from OS to OS and it should be minimum, which is assigned to a specific time.
Round Robin Criteria
- Time Quantum
- Arrival Time
Round Robin Decision Mode
- Preemptive: each process is allowed to run for a specified time duration, called its quantum. The process is allowed to run only for this time interval.
- Non-Preemptive: for that, maintain the ready queue. First, come process executes till the time quantum value and likewise, processes are executes
Round Robin Implementation
- This strategy can be implemented by using a circular FIFO queue in the Round Robin Scheduling algorithm.
For Example
In this, it has time quantum is 4, and context switch overhead is 1.
Process | Arrival Time (A.T.) | Burst Time (B.T.) |
P0 | 0 | 10 |
P1 | 1 | 6 |
P2 | 3 | 2 |
P3 | 5 | 4 |
Gantt Chart
Process | Arrival Time | Burst Time | Completion Time | Turnaround Time | Waiting Time |
P0 | 0 | 10 | 28 | 28 | 18 |
P1 | 1 | 6 | 25 | 24 | 18 |
P2 | 3 | 2 | 12 | 9 | 7 |
P3 | 5 | 4 | 22 | 17 | 13 |
Average Turnaround Time:(28+24+9+17)/4 = 19.5
Average Waiting Time: (18+18+7+13)/4 = 14
Advantages
- One of the oldest, simplest, fairest, and most widely used algorithms.
- It deals with all processes without any priority and worry.
- That’s performance is very good than another algorithm in terms of average responding time.
- It does not face any difficulty in the convoy effect.
- CPU allocation is distributed by the algorithm fairly.
- If one process is specified in the set of the time period, the process is preempted, and another process will start within that time period.
- this scheduling algorithm does not depend on the burst time, which is helpful to easily implement to any operating system.
Disadvantages
- Context switch overhead is there.
- The time spends by context switching is more.
- It decreases comprehension.
- When higher context switching is implemented we get lower quantum results.
- The priorities can’t be set for the processes.
- Difficult to find the correct timing of quantum in the algorithm.
- The performance heavily depends on the quantum.
- It doesn’t give special priority to the important task.
Worst Case Latency
This term is used for the maximum time taken for the execution of all task mentions.
- dt –> It denotes the detection time in which task is brought to the list.
- st –>Switching task from one task to another one task.
- et –> It denotes the task execution time.
Determination of time quantum is too critical. If it is too long it causes poor response for sort interactive processes.
Implementation of RR in C language
#include<stdio.h>
int main()
{
int count,j,n,time,remain,flag=0,time_quantum;
int wait_time=0,turnaround_time=0,at[10],bt[10],rt[10];
printf("Enter Total Process: ");
scanf("%d",&n);
remain=n;
for(count=0;count<n;count++)
{
printf("Enter Arrival Time and Burst Time for Process Process Number %d :",count+1);
scanf("%d",&at[count]);
scanf("%d",&bt[count]);
rt[count]=bt[count];
}
printf("Enter Time Quantum:\t");
scanf("%d",&time_quantum);
printf("\n\nProcess\t|Turnaround Time|Waiting Time\n\n");
for(time=0,count=0;remain!=0;)
{
if(rt[count]<=time_quantum && rt[count]>0)
{
time+=rt[count];
rt[count]=0;
flag=1;
}
else if(rt[count]>0)
{
rt[count]-=time_quantum;
time+=time_quantum;
}
if(rt[count]==0 && flag==1)
{
remain--;
printf("P[%d]\t|\t%d\t|\t%d\n",count+1,time-at[count],time-at[count]-bt[count]);
wait_time+=time-at[count]-bt[count];
turnaround_time+=time-at[count];
flag=0;
}
if(count==n-1)
count=0;
else if(at[count+1]<=time)
count++;
else
count=0;
}
printf("\nAverage Waiting Time= %f\n",wait_time*1.0/n);
printf("Avg Turnaround Time = %f",turnaround_time*1.0/n);
return 0;
}
In conclusion, Any query in RR Comment below in the comment box.
To learn more concept about RR go to
Summary
- The Robin Scheduling Algorithm is a pre-emptive algorithm and it is used mostly in old OS
- It is very easy to understand and we can easily execute.
https://www.geeksforgeeks.org/program-round-robin-scheduling-set-1/
For Android projects goto the ANDROID
Stay Connect with our app
https://play.google.com/store/apps/details?id=com.edu.easyengineer
For Assignment Questions and Explanation of a theory topic visit
Be the first to comment