-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathps.c
54 lines (50 loc) · 1.42 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
53
54
#include "types.h"
#include "stat.h"
#include "user.h"
int main(void) {
struct procps ps_array[MAX_PS_PROCS];
struct procps *start;
sysps((unsigned long)MAX_PS_PROCS * sizeof(struct procps),ps_array);
start = &ps_array[0];
printf (1,"SZ PGDIR STATE PID KILLED CHAN NAME PARENT_PID EDI\n");
while(start != &ps_array[MAX_PS_PROCS-1] && start->pid != 0){
printf (1,"%d ", start->sz);
printf (1,"%p ", start->pgdir);
switch (start->state)
{
case 0:
printf (1,"UNUSED ");
break;
case 1:
printf (1,"EMBRYO ");
break;
case 2:
printf (1,"SLEEPING ");
break;
case 3:
printf (1,"RUNNABLE ");
break;
case 4:
printf (1,"RUNNING ");
break;
case 5:
printf (1,"ZOMBIE ");
break;
default:
break;
}
printf (1,"%d ", start->pid);
if(start->killed < 0){
printf (1,"KILLED ");
} else {
printf (1,"ALIVE ");
}
printf (1,"%d ", start->chan);
printf (1,start->name);
printf (1," %d ", start->parent_pid);
printf (1," %d ", (int)start->edi);
printf (1,"\n");
start++;
}
exit();
}