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
;
23 #define MYPANIC(msg) { \
24 static char buf[100]; \
27 util_nstrcat(buf, line);\
30 minix_panic(buf, NO_NUM); \
33 for (xp
= BEG_PROC_ADDR
; xp
< END_PROC_ADDR
; ++xp
) {
35 if (l
++ > MAX_LOOP
) { MYPANIC("check error"); }
38 for (q
=l
=0; q
< NR_SCHED_QUEUES
; q
++) {
39 if (rdy_head
[q
] && !rdy_tail
[q
]) {
40 kprintf("head but no tail in %d\n", q
);
41 MYPANIC("scheduling error");
43 if (!rdy_head
[q
] && rdy_tail
[q
]) {
44 kprintf("tail but no head in %d\n", q
);
45 MYPANIC("scheduling error");
47 if (rdy_tail
[q
] && rdy_tail
[q
]->p_nextready
!= NIL_PROC
) {
48 kprintf("tail and tail->next not null in %d\n", q
);
49 MYPANIC("scheduling error");
51 for(xp
= rdy_head
[q
]; xp
!= NIL_PROC
; xp
= xp
->p_nextready
) {
53 kprintf("scheduling error: unready on runq %d proc %d\n",
55 MYPANIC("found unready process on run queue");
57 if (xp
->p_priority
!= q
) {
58 kprintf("scheduling error: wrong priority q %d proc %d\n",
60 MYPANIC("wrong priority");
63 kprintf("scheduling error: double sched q %d proc %d\n",
65 MYPANIC("proc more than once on scheduling queue");
68 if (xp
->p_nextready
== NIL_PROC
&& rdy_tail
[q
] != xp
) {
69 kprintf("sched err: last element not tail q %d proc %d\n",
71 MYPANIC("scheduling error");
73 if (l
++ > MAX_LOOP
) MYPANIC("loop in schedule queue?");
78 for (xp
= BEG_PROC_ADDR
; xp
< END_PROC_ADDR
; ++xp
) {
79 if (! isemptyp(xp
) && xp
->p_ready
&& ! xp
->p_found
) {
80 kprintf("sched error: ready proc %d not on queue\n", xp
->p_nr
);
81 MYPANIC("ready proc not on scheduling queue");
82 if (l
++ > MAX_LOOP
) { MYPANIC("loop in debug.c?"); }
87 #endif /* DEBUG_SCHED_CHECK */