don't suspend the process as a side-effect if
[minix.git] / kernel / debug.c
blob0a5a4723e798856012cd37f114e8c8e66621e430
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.
4 */
6 #include "kernel.h"
7 #include "proc.h"
8 #include "debug.h"
10 #include <minix/sysutil.h>
11 #include <limits.h>
12 #include <string.h>
14 #if DEBUG_SCHED_CHECK /* only include code if enabled */
16 #define MAX_LOOP (NR_PROCS + NR_TASKS)
18 PUBLIC void
19 check_runqueues_f(char *file, int line)
21 int q, l = 0;
22 register struct proc *xp;
23 #define MYPANIC(msg) { \
24 static char buf[100]; \
25 strcpy(buf, file); \
26 strcat(buf, ": "); \
27 util_nstrcat(buf, line);\
28 strcat(buf, ": "); \
29 strcat(buf, msg); \
30 minix_panic(buf, NO_NUM); \
33 for (xp = BEG_PROC_ADDR; xp < END_PROC_ADDR; ++xp) {
34 xp->p_found = 0;
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) {
52 if (!xp->p_ready) {
53 kprintf("scheduling error: unready on runq %d proc %d\n",
54 q, xp->p_nr);
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",
59 q, xp->p_nr);
60 MYPANIC("wrong priority");
62 if (xp->p_found) {
63 kprintf("scheduling error: double sched q %d proc %d\n",
64 q, xp->p_nr);
65 MYPANIC("proc more than once on scheduling queue");
67 xp->p_found = 1;
68 if (xp->p_nextready == NIL_PROC && rdy_tail[q] != xp) {
69 kprintf("sched err: last element not tail q %d proc %d\n",
70 q, xp->p_nr);
71 MYPANIC("scheduling error");
73 if (l++ > MAX_LOOP) MYPANIC("loop in schedule queue?");
77 l = 0;
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 */