forked from 48ca/xv6-public
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ps.c
37 lines (29 loc) · 928 Bytes
/
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
#include "types.h"
#include "pstat.h"
#include "user.h"
#include "param.h"
void showps(struct pstat* ps) {
int i;
printf(1, "Process stats:\n-----------------\n");
printf(1, "PID | name | state | size (pages) | ticks\n---------------\n");
if ((getpstat(ps)) < 0)
{
printf(2, "Unable to load ptstat\n");
exit();
}
for (i=0; i<NPROC; i++) {
if (ps->state[i] > 0) {
printf(1, "%d | %s | %d | %d | %d \n", ps->pid[i],
ps->name[i],
ps->state[i],
ps->pages[i],
ps->ticks[i]
);
}
}
}
int main(int argc, char* argv[]) {
struct pstat ps;
showps(&ps);
exit();
}