1 /* This file contains procedures to dump to PM' data structures.
3 * The entry points into this file are
4 * mproc_dmp: display PM process table
7 * May 11, 2005: by Jorrit N. Herder
11 #include "../pm/mproc.h"
13 #include <minix/config.h>
14 #include <minix/type.h>
16 PUBLIC
struct mproc mproc
[NR_PROCS
];
18 /*===========================================================================*
20 *===========================================================================*/
21 PRIVATE
char *flags_str(int flags
)
24 str
[0] = (flags
& WAITING
) ? 'W' : '-';
25 str
[1] = (flags
& ZOMBIE
) ? 'Z' : '-';
26 str
[2] = (flags
& PAUSED
) ? 'P' : '-';
27 str
[3] = (flags
& ALARM_ON
) ? 'A' : '-';
28 str
[4] = (flags
& TRACED
) ? 'T' : '-';
29 str
[5] = (flags
& STOPPED
) ? 'S' : '-';
30 str
[6] = (flags
& SIGSUSPENDED
) ? 'U' : '-';
31 str
[7] = (flags
& REPLY
) ? 'R' : '-';
32 str
[8] = (flags
& ONSWAP
) ? 'O' : '-';
33 str
[9] = (flags
& SWAPIN
) ? 'I' : '-';
34 str
[10] = (flags
& DONT_SWAP
) ? 'D' : '-';
35 str
[11] = (flags
& PRIV_PROC
) ? 'P' : '-';
41 PUBLIC
void mproc_dmp()
45 static int prev_i
= 0;
47 printf("Process manager (PM) process table dump\n");
49 getsysinfo(PM_PROC_NR
, SI_PROC_TAB
, mproc
);
51 printf("-process- -nr-prnt- -pid/ppid/grp- -uid--gid- -nice- -flags------\n");
52 for (i
=prev_i
; i
<NR_PROCS
; i
++) {
54 if (mp
->mp_pid
== 0 && i
!= PM_PROC_NR
) continue;
56 printf("%8.8s %4d%4d %4d%4d%4d ",
57 mp
->mp_name
, i
, mp
->mp_parent
, mp
->mp_pid
, mproc
[mp
->mp_parent
].mp_pid
, mp
->mp_procgrp
);
58 printf("%d(%d) %d(%d) ",
59 mp
->mp_realuid
, mp
->mp_effuid
, mp
->mp_realgid
, mp
->mp_effgid
);
61 mp
->mp_nice
, flags_str(mp
->mp_flags
));
64 if (i
>= NR_PROCS
) i
= 0;
65 else printf("--more--\r");
69 /*===========================================================================*
71 *===========================================================================*/
72 PUBLIC
void sigaction_dmp()
76 static int prev_i
= 0;
79 printf("Process manager (PM) signal action dump\n");
81 getsysinfo(PM_PROC_NR
, SI_PROC_TAB
, mproc
);
84 printf("-process- -nr- --ignore- --catch- --block- -tomess-- -pending-- -alarm---\n");
85 for (i
=prev_i
; i
<NR_PROCS
; i
++) {
87 if (mp
->mp_pid
== 0 && i
!= PM_PROC_NR
) continue;
89 printf("%8.8s %3d ", mp
->mp_name
, i
);
90 printf(" 0x%06x 0x%06x 0x%06x 0x%06x ",
91 mp
->mp_ignore
, mp
->mp_catch
, mp
->mp_sigmask
, mp
->mp_sig2mess
);
92 printf("0x%06x ", mp
->mp_sigpending
);
93 if (mp
->mp_flags
& ALARM_ON
) printf("%8u", mp
->mp_timer
.tmr_exp_time
-uptime
);
97 if (i
>= NR_PROCS
) i
= 0;
98 else printf("--more--\r");
102 /*===========================================================================*
104 *===========================================================================*/
105 PUBLIC
void holes_dmp(void)
107 static struct pm_mem_info pmi
;
109 int largest_bytes
= 0, total_bytes
= 0;
111 if(getsysinfo(PM_PROC_NR
, SI_MEM_ALLOC
, &pmi
) != OK
) {
112 printf("Obtaining memory hole list failed.\n");
115 printf("Available memory stats\n");
117 for(h
= 0; h
< _NR_HOLES
; h
++) {
118 if(pmi
.pmi_holes
[h
].h_base
&& pmi
.pmi_holes
[h
].h_len
) {
120 bytes
= (pmi
.pmi_holes
[h
].h_len
<< CLICK_SHIFT
);
121 printf("%08lx: %6d kB\n",
122 pmi
.pmi_holes
[h
].h_base
<< CLICK_SHIFT
, bytes
/ 1024);
123 if(bytes
> largest_bytes
) largest_bytes
= bytes
;
124 total_bytes
+= bytes
;
128 "Total memory free: %7d kB\n"
129 "Largest chunk: %7d kB\n"
130 "Uncontiguous rest: %7d kB (%d%% of total free)\n"
131 "Memory high watermark: %7d kB\n",
134 (total_bytes
-largest_bytes
)/1024,
135 100*(total_bytes
/100-largest_bytes
/100)/total_bytes
,
136 (pmi
.pmi_hi_watermark
/1024 << CLICK_SHIFT
));