-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathround.cpp
More file actions
59 lines (52 loc) · 1.07 KB
/
Copy pathround.cpp
File metadata and controls
59 lines (52 loc) · 1.07 KB
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
#include<iostream>
using namespace std;
int main()
{
int at[10],bt[10],rt[10],tat,time_slice;
int time=0,left,count=0,n,i,flag=0;
cout<<"\n Enter the number of Processes :";
cin>>n;
left=n;
for(i=0;i<n;i++)
{
cout<<"\n Enter burst time | Arrival time for Processes: <<"<<i<<">>";
cin>>bt[i]>>at[i];
rt[i]=bt[i];
}
cout<<"\n Enter Time Slice : ";
cin>>time_slice;
cout<<"Processes\t Burst Time\t Arrival Time \t TAT \tWaiting Time";
for(time=0,count=0;left!=0;)
{ cout<<"\ncount = "<<count;
if(rt[count]<=time_slice && rt[count]>0)
{
time+=rt[count];
rt[count]=0;
flag=1;
}
else if(rt[count]>time_slice)
{
time+=time_slice;
rt[count]-=time_slice;
}
if(rt[count]==0 && flag==1)
{
cout<<"\ncount = "<<count;
cout<<"\nP["<<count+1<<"]\t\t"<<bt[count]<<"\t\t"<<at[count]<<"\t\t"<<time-at[count]<<"\t\t"<<time-at[count]-bt[count];
flag=0;
left--;
}
if(count==n-1)
{
count=0;
}
else if(at[count+1]<=time)
{
count++;
}
else
{
count=0;
}
}
}