-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmultiple_jobs_io.c
61 lines (54 loc) · 1.44 KB
/
multiple_jobs_io.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
#include "types.h"
#include "stat.h"
#include "user.h"
#include "pstat.h"
#define check(exp, msg) if(exp) {} else { \
printf(1, "%s:%d check (" #exp ") failed: %s\n", __FILE__, __LINE__, msg); \
exit();}
int pow2[] = {80000000, 32, 16, 8};
char buf[10000]; // ~10KB
int
workload(int n) {
int i, j = 0;
for(i = 0; i < n; i++)
j += i * j + 1;
return j;
}
int
main(int argc, char *argv[])
{
struct pstat st;
sleep(10);
int i, j;
for (i = 0; i < sizeof(buf); i++)
buf[i] = 'a';
char* test_file = "README";
int fd = open(test_file, 0x002);
for (i = 0; i <= 60; i++) {
if (fork() == 0) {
read(fd, buf, i * 100);
if (i == NPROC - 4) {
check(getpinfo(&st) == 0, "getpinfo");
for(i = 0; i < NPROC; i++) {
if (st.inuse[i]) {
printf(1, "pid: %d priority: %d ticks: %d\n", st.pid[i], st.priority[i], st.ticks[i][3]);
if (st.pid[i] > 3) {
check(st.ticks[i][3] > 0, "Every process at the highest level should use at least 1 timer tick");
}
for (j = 3; j > st.priority[i]; j--) {
check(st.ticks[i][j] == pow2[j], "incorrect #ticks at this level");
}
check(st.ticks[i][j] < pow2[j],
"#ticks at this level should not exceed the maximum allowed");
}
}
printf(1, "TEST PASSED");
}
} else {
wait();
break;
}
}
close(fd);
exit();
}