-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathos Project.c
62 lines (50 loc) · 1.35 KB
/
os Project.c
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
#include<stdio.h>
#include<conio.h>
#include<unistd.h>
struct Process{
int burst_time, queue_no;
int running;
};
int main(){
int n, i = 0, r = 0, j =0, k = 0;
printf("Enter the number of processes: ");
scanf("%d", &n);
struct Process P[n];
// getting info about processes directly from the user
// containing burst time, priority
for(i = 0; i < n; i++){
printf("\nFor Process %d\n\n", i + 1);
printf("Enter burst time : ");
scanf("%d", &P[i].burst_time);
printf("Enter Queue Number: ");
scanf("%d", &P[i].queue_no);
}
while(P[0].queue_no != -1 && P[1].queue_no != -1 && P[2].queue_no != -1){
for(i = 0; i < n; i++){
if(P[i].queue_no == 1){
if(P[i].burst_time >= 4){
if(r == 10){
break;
}
r = r + 4;
P[i].burst_time = P[i].burst_time - 4;
P[i].running = r;
printf("%d Process is executed till %d", i+1, r);
}
else{
if(r == 10){
break;
}
r = r + P[i].burst_time;
P[i].burst_time = P[i].burst_time - P[i].burst_time;
P[i].running = r;
printf("\n%d Process is executed till %d", i+1, r);
P[i].queue_no = -1;
}
}
}
}
printf("\n\nProcess 1 burst time = %d and r = %d", P[0].burst_time, r);
printf("\nProcess 1 Running time: %d, 2 Running time = %d", P[0].running, P[2].running);
return 0;
}