1 /* This file implements kernel debugging functionality that is not included
2 * in the standard kernel. Available functionality includes timing of lock
3 * functions and sanity checking of the scheduling queues.
10 #include <minix/sysutil.h>
14 #if DEBUG_SCHED_CHECK /* only include code if enabled */
16 #define MAX_LOOP (NR_PROCS + NR_TASKS)
19 check_runqueues_f(char *file
, int line
)
22 register struct proc
*xp
;
24 if(!intr_disabled()) {
25 minix_panic("check_runqueues called with interrupts enabled", NO_NUM
);
28 FIXME("check_runqueues being done");
30 #define MYPANIC(msg) { \
31 kprintf("check_runqueues:%s:%d: %s\n", file, line, msg); \
32 minix_panic("check_runqueues failed", NO_NUM); \
35 for (xp
= BEG_PROC_ADDR
; xp
< END_PROC_ADDR
; ++xp
) {
37 if (l
++ > MAX_LOOP
) { MYPANIC("check error"); }
40 for (q
=l
=0; q
< NR_SCHED_QUEUES
; q
++) {
41 if (rdy_head
[q
] && !rdy_tail
[q
]) {
42 kprintf("head but no tail in %d\n", q
);
43 MYPANIC("scheduling error");
45 if (!rdy_head
[q
] && rdy_tail
[q
]) {
46 kprintf("tail but no head in %d\n", q
);
47 MYPANIC("scheduling error");
49 if (rdy_tail
[q
] && rdy_tail
[q
]->p_nextready
!= NIL_PROC
) {
50 kprintf("tail and tail->next not null in %d\n", q
);
51 MYPANIC("scheduling error");
53 for(xp
= rdy_head
[q
]; xp
!= NIL_PROC
; xp
= xp
->p_nextready
) {
54 vir_bytes vxp
= (vir_bytes
) xp
, dxp
;
55 if(vxp
< (vir_bytes
) BEG_PROC_ADDR
|| vxp
>= (vir_bytes
) END_PROC_ADDR
) {
56 MYPANIC("xp out of range");
58 dxp
= vxp
- (vir_bytes
) BEG_PROC_ADDR
;
59 if(dxp
% sizeof(struct proc
)) {
60 MYPANIC("xp not a real pointer");
62 if(xp
->p_magic
!= PMAGIC
) {
63 MYPANIC("magic wrong in xp");
65 if (RTS_ISSET(xp
, SLOT_FREE
)) {
66 kprintf("scheduling error: dead proc q %d %d\n",
68 MYPANIC("dead proc on run queue");
71 kprintf("scheduling error: unready on runq %d proc %d\n",
73 MYPANIC("found unready process on run queue");
75 if (xp
->p_priority
!= q
) {
76 kprintf("scheduling error: wrong priority q %d proc %d ep %d name %s\n",
77 q
, xp
->p_nr
, xp
->p_endpoint
, xp
->p_name
);
78 MYPANIC("wrong priority");
81 kprintf("scheduling error: double sched q %d proc %d\n",
83 MYPANIC("proc more than once on scheduling queue");
86 if (xp
->p_nextready
== NIL_PROC
&& rdy_tail
[q
] != xp
) {
87 kprintf("sched err: last element not tail q %d proc %d\n",
89 MYPANIC("scheduling error");
91 if (l
++ > MAX_LOOP
) MYPANIC("loop in schedule queue?");
96 for (xp
= BEG_PROC_ADDR
; xp
< END_PROC_ADDR
; ++xp
) {
97 if(xp
->p_magic
!= PMAGIC
)
98 MYPANIC("p_magic wrong in proc table");
101 if(xp
->p_ready
&& ! xp
->p_found
) {
102 kprintf("sched error: ready proc %d not on queue\n", xp
->p_nr
);
103 MYPANIC("ready proc not on scheduling queue");
104 if (l
++ > MAX_LOOP
) { MYPANIC("loop in debug.c?"); }
109 #endif /* DEBUG_SCHED_CHECK */
112 rtsflagstr(int flags
)
114 static char str
[100];
117 #define FLAG(n) if(flags & n) { strcat(str, #n " "); }
137 miscflagstr(int flags
)
139 static char str
[100];