-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram for RRS
64 lines (60 loc) · 1.62 KB
/
Program for RRS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include<stdio.h>
void main()
{
int n,i,qt,count=0,temp=0,sq=0,bt[10],wt[10],tat[10],rem_bt[10];
float awt=0,atat=0;
printf("Enter no. of Process: ");
scanf("%d",&n);
printf("Enter Burst Time of Process: ");
for(i=0;i<n;i++)
{
scanf("%d",&bt[i]);
rem_bt[i]=bt[i];
}
printf("Enter the Quantum Time: ");
scanf("%d",&qt);
while(1)
{
for(i=0,count=0;i<n;i++)
{
temp=qt;
if(rem_bt[i]==0)
{
count++;
continue;
}
if(rem_bt[i]>qt)
{
rem_bt[i]=rem_bt[i]-qt;
}
else
if(rem_bt>=0)
{
temp=rem_bt[i];
rem_bt[i]=0;
}
sq=sq+temp;
tat[i]=sq;
}
if(n==count)
break;
}
printf("\nProcess\tBurst Time\tTurn Around Time\tWaiting Time\n");
for(i=0;i<n;i++)
{
wt[i]=tat[i]-bt[i];
awt=awt+wt[i];
atat=atat+tat[i];
printf("\n%d\t%d\t\t%d\t\t\t%d",i+1,bt[i],tat[i],wt[i]);
}
printf("\nAverage Waiting Time = %f\n",awt/n);
printf("Average Turn Around Time = %f\n",atat/n);
}
OUTPUT:
Process Burst Time Turn Around Time Waiting Time
1 5 13 8
2 3 10 7
3 1 5 4
4 4 12 8
Average Waiting Time = 6.750000
Average Turn Around Time = 10.000000