forked from mit-pdos/xv6-public
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathps.c
52 lines (48 loc) · 1.35 KB
/
ps.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
#include "param.h"
#include "types.h"
#include "fcntl.h"
#include "stat.h"
#include "user.h"
#include "procstat.h"
struct procstat buf[NPROC];
// enum procstate { UNUSED, EMBRYO, SLEEPING, RUNNABLE, RUNNING, ZOMBIE };
int main(int argc, char** argv) {
procinfo(buf);
printf(1, "pid\tprty\tstate \trtime\twtime\tnrun\t");
#ifdef MLFQ
printf(1, "currq\tq0\tq1\tq2\tq3\tq4\n");
#endif
for(int i = 0; i < NPROC; i++){
if(buf[i].pid > 0 && buf[i].state > 0){
printf(1,"%d\t%d\t", buf[i].pid, buf[i].priority);
switch (buf[i].state){
case 1:
printf(1,"embryo \t");
break;
case 2:
printf(1,"sleeping\t");
break;
case 3:
printf(1,"waiting \t");
break;
case 4:
printf(1,"running \t");
break;
case 5:
printf(1,"zombie \t");
break;
default:
break;
}
printf(1, "%d\t%d\t%d\t", buf[i].rtime, buf[i].wtime, buf[i].nrun);
#ifdef MLFQ
printf(1, "%d\t", buf[i].curq);
for(int j = 0; j < NQUEUE; j++){
printf(1, "%d\t",buf[i].ticks[j]);
}
#endif
printf(1, "\n");
}
}
exit();
}