Round Robin Scheduling Algorithm
The round-robin (RR)
scheduling algorithm is designed especially for time-sharing systems. It is similar to FCFS scheduling, but
pre-preemption is added to switch between processes. A small unit of time,
called a time quantum or time slice, is defined. A time quantum is generally from 10
to 100 milliseconds. The ready queue is treated as a circular
queue.
or
It is one of the oldest, simplest, and fairest and
most widely used scheduling algorithms, designed especially for time-sharing
systems. A small unit of time, called time-slice or quantum, is
defined. All runnable processes are kept in a circular queue. The CPU scheduler
goes around this queue, allocating the CPU to each process for a time interval
of one quantum. New processes are added to the tail of the queue.
CPU : Central Processing Unit
C program for solving round robin
Algorithm : without arrival time
#include<stdio.h>
void main()
{
int j,q,i,n,ts;
int aw; //total waiting time
float awt; //average waiting time
int bt[10],wt[10],te[10],rt[10];j=0; clrscr();
printf("enter number of process :\t");
scanf("%d",&n);
printf("\n enter brust time \n");
for(i=0;i<n;i++)
{
printf("P%d\t",i+1);
scanf("%d",&bt[i]);
rt[i]=bt[i];
te[i]=0; wt[i]=0;
printf("\n enter time slice\t");
scanf("%d",&ts); q=0; clrscr();
printf("\nprocess :") ;
for(i=0;i<n;i++)
{
printf(" %d",i+1);
}
printf("\nBrust time :");
for(i=0;i<n;i++)
{
printf(" %d",bt[i]);
}
printf("\n Gaint chart \n");
while(j<=n)
{
j++;
j++;
for(i=0;i<n;i++)
{
if(rt[i]==0) continue;
if(rt[i]>ts)
{
printf("\n %d\t P%d",q,i+1);
q=q+ts;
rt[i]=rt[i]-ts;
te[i]=te[i]+1;
}
else
{
{
printf("\n %d\t P%d",q,i+1);
wt[i]=q-te[i]*ts;
q=q+rt[i];
rt[i]=rt[i]-rt[i];
rt[i]=rt[i]-rt[i];
}
}
} //end of while loop
awt=0;
awt=0;
printf("\n Process Waitnig time");
for(i=0;i<n;i++)
{
printf("\n P%d : %d",i+1,wt[i]); awt=awt+wt[i];
}
aw=awt;
aw=awt;
printf("\ntotal waiting time %d",aw);
printf("\n Avg wainting time %f ",awt/n);
getch();
}
OUTPUT:-
Burst Time is actually time that is required to complete execution of particular task or process.
Comments