Implementation of Round Robin Scheduling Algorithm Using C
Implementation of Round Robin Scheduling Algorithm Using C
#include<stdio.h>
void main()
scanf("%d", &NOP);
y = NOP;
printf("\n Enter the Arrival and Burst time of the Process[%d]\n", i+1);
scanf("%d", &at[i]);
scanf("%d", &bt[i]);
temp[i] = bt[i];
scanf("%d", &quant);
printf("\n Process No \t\t Burst Time \t\t TAT \t\t Waiting Time ");
for(sum=0, i = 0; y!=0; )
{
sum = sum + temp[i];
temp[i] = 0;
count=1;
y--;
printf("\nProcess No[%d] \t\t %d\t\t\t\t %d\t\t\t %d", i+1, bt[i], sum-at[i], sum-at[i]-bt[i]);
wt = wt+sum-at[i]-bt[i];
tat = tat+sum-at[i];
count =0;
if(i==NOP-1)
i=0;
else if(at[i+1]<=sum)
i++;
else
i=0;
}
avg_wt = wt * 1.0/NOP;
Output:
/tmp/oAmSOSF4ms.o
Process No[1] 2 2 0
Process No[2] 3 6 3
Process No[3] 2 4 2