-
Notifications
You must be signed in to change notification settings - Fork 1
/
getpinfo.c
41 lines (34 loc) · 866 Bytes
/
getpinfo.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
#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
main(int argc, char *argv[])
{
struct pstat st;
check(getpinfo(&st) == 0, "getpinfo");
int i, j;
int pid = getpid();
int found_self = 0;
for(i = 0; i < NPROC; i++) {
if (st.inuse[i]) {
printf(1, "pid: %d priority: %d\n ", st.pid[i], st.priority[i]);
if (st.pid[i] == pid) {
found_self = 1;
}
for (j = 3; j >= 0; j--) {
printf(1, "\t level %d ticks used %d\n", j, st.ticks[i][j]);
printf(1, "\t level %d ticks waited for %d\n", j, st.wait_ticks[i][j]);
}
}
}
if (found_self) {
printf(1, "TEST PASSED");
} else {
printf(1, "TEST FAILED");
}
exit();
}