-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCPUschedulingFCFS.cpp
More file actions
56 lines (47 loc) · 875 Bytes
/
CPUschedulingFCFS.cpp
File metadata and controls
56 lines (47 loc) · 875 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
49
50
51
52
53
54
55
56
#include<iostream>
using namespace std;
typedef struct process
{
int at;
int et;
int ct;
} process;
int main()
{
process p[5];
int time = 0;
int i=0;
int j=0;
p[0].at = 3;
p[0].et = 1;
p[1].at = 1;
p[1].et = 4;
p[2].at = 4;
p[2].et = 2;
p[3].at = 0;
p[3].et = 6;
p[4].at = 2;
p[4].et = 3;
for(i=0;i<5;i++)
{
for(j=i+1;j<5;j++)
{
if(p[i].at>p[j].at)
{
process arrival = p[i];
p[i] = p[j];
p[j] = arrival;
}
}
}
for(i=0;i<5;i++)
{ if(time < p[i].at)
{
time = p[i].at;
}
p[i].ct = time + p[i].et;
time = p[i].ct;
cout << p[i].ct << endl;
}
return 0;
}