-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRobin Round.cpp
More file actions
48 lines (46 loc) · 1013 Bytes
/
Robin Round.cpp
File metadata and controls
48 lines (46 loc) · 1013 Bytes
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
#include<iostream>
using namespace std;
int main()
{
int i,j,n,bu[10],wa[10],tat[10],t,ct[10],max;
float awt=0,att=0,temp=0;
cout << "Enter the number of processes--";
cin >> n;
for(i=0;i<n;i++)
{
cout << "\nEnter Burst time for process " << i+1 << " :";
cin >> bu[i];
ct[i]=bu[i];
}
cout << "Enter the size of time slice--";
cin >> t;
max=bu[0];
for(i=1;i<n;i++)
if(max<bu[i])
max=bu[i];
for(j=0;j<(max/t)+1;j++)
for(i=0;i<n;i++) if(bu[i]!=0)
if(bu[i]<=t)
{
tat[i]=temp+bu[i];
temp=temp+bu[i];
bu[i]=0;
}
else
{
bu[i]=bu[i]-t;
temp=temp+t;
}
for(i=0;i<n;i++)
{
wa[i]=tat[i]-
ct[i]; att+=tat[i];
awt+=wa[i];
}
cout << "\n\tPROCESS\t BURST TIME \t WAITING TIME\tTURNAROUND TIME\n";
for(i=0;i<n;i++)
cout << "\t " << i+1 << "\t" << ct[i] << "\t" << wa[i] <<"\t" << tat[i];
cout << "\n\nThe Average Turn around is--" << att/n << endl; ;
cout << "The Average Waiting time is -- " << awt/n << endl;
return 0;
}