-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSCFS.cpp
More file actions
61 lines (39 loc) · 958 Bytes
/
SCFS.cpp
File metadata and controls
61 lines (39 loc) · 958 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
57
58
59
60
61
#include<stdio.h>
int main(){
int bt[10]={0},at[10]={0},tat[10]={0},wt[10]={0},ct[10]={0};
int n,sum=0;
float totalTAT=0,totalWT=0;
printf("Enter number of processes: ");
scanf("%d",&n);
printf("Process name Arrival time Cpu time:\n\n");
for(int i=0;i<n;i++)
{
printf("Arrival time of process[%d] ",i+1);
scanf("%d",&at[i]);
printf("Burst time of process[%d] ",i+1);
scanf("%d",&bt[i]);
printf("\n");
}
for(int j=0;j<n;j++)
{
sum+=bt[j];
ct[j]+=sum;
}
for(int k=0;k<n;k++)
{
tat[k]=ct[k]-at[k];
totalTAT+=tat[k];
}
for(int k=0;k<n;k++)
{
wt[k]=tat[k]-bt[k];
totalWT+=wt[k];
}
printf("Solution Output: \n\n");
for(int i=0;i<n;i++)
{
printf("\nProcess %d: Waiting Time:%d Turnaround Time:%d\n\n",i+1,wt[i],tat[i]);
}
printf("\n\nAverage Turnaround Time = %f\n\n",totalTAT/n);
printf("Average Waiting Time = %f\n\n",totalWT/n);
}