-
Notifications
You must be signed in to change notification settings - Fork 0
/
cttest.c
75 lines (71 loc) · 1.26 KB
/
cttest.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
63
64
65
66
67
68
69
70
71
72
73
74
75
#include "types.h"
#include "stat.h"
#include "user.h"
void mysleep(int loop){
int upt = uptime();
while(upt + loop > uptime()){
}
}
void print_loop(const char* inp){
for(int i=0;i<5;i++){
//
printf(1,"%s\n",inp);
mysleep(20);
}
print_process();
exit();
}
int main(int argc, char *argv[]){
if(!fork()){
sleep(50);
set_priority(5);
sleep(50);
print_loop("pr:5");
}
if(!fork()){
sleep(50);
set_priority(2);
sleep(50);
print_loop("pr:2");
}
if(!fork()){
sleep(50);
set_fcfs();
sleep(50);
print_loop("fcfs:1");
}
if(!fork()){
sleep(50);
set_fcfs();
sleep(50);
print_loop("fcfs:2");
}
if(!fork()){
sleep(50);
set_luck(4);
sleep(50);
print_loop("luck");
}
if(!fork()){
sleep(50);
set_luck(3000);
sleep(50);
print_loop("luck22");
}
if(!fork()){
sleep(50);
set_luck(3000);
sleep(50);
print_loop("luck2");
}
printf(1,"created\n");
wait();
printf(1,"passed\n");
wait();
wait();
wait();
wait();
wait();
wait();
exit();
}