From: Ben Gras Date: Tue, 24 May 2005 12:33:03 +0000 (+0000) Subject: added a debugging functionality in system/debugging.c (to check sanity of X-Git-Tag: v3.1.0~816 X-Git-Url: http://zhaoyanbai.com/repos/rndc-confgen.html?a=commitdiff_plain;h=804cb810d0262bcad49e6fd7ddb641339636b096;p=minix.git added a debugging functionality in system/debugging.c (to check sanity of run queues) and associated prototype in system.h --- diff --git a/kernel/system.h b/kernel/system.h index a57e3914f..403843f25 100644 --- a/kernel/system.h +++ b/kernel/system.h @@ -62,8 +62,7 @@ _PROTOTYPE( int do_trace, (message *m_ptr) ); /* process tracing */ #endif #if ENABLE_K_DEBUGGING /* debugging */ -#error Kernel debugging routines are not implemented. -#else +_PROTOTYPE( void check_runqueues, (char *when) ); #endif _PROTOTYPE( int do_vircopy, (message *m_ptr) ); diff --git a/kernel/system/debugging.c b/kernel/system/debugging.c index 2cc5aea66..e683b4299 100644 --- a/kernel/system/debugging.c +++ b/kernel/system/debugging.c @@ -6,9 +6,69 @@ #include "../kernel.h" #include "../system.h" +#include "../proc.h" #if ENABLE_K_DEBUGGING /* only include code if enabled */ +#define PROCLIMIT 10000 + +PUBLIC void +check_runqueues(char *when) +{ + int q, l = 0; + register struct proc *xp; + + for (xp = BEG_PROC_ADDR; xp < END_PROC_ADDR; ++xp) { + xp->p_found = 0; + if(l++ > PROCLIMIT) { panic("check error", NO_NUM); } + } + + for (q=0; q < NR_SCHED_QUEUES; q++) { + if(rdy_head[q] && !rdy_tail[q]) { + kprintf("head but no tail: %s", (karg_t) when); + panic("scheduling error", NO_NUM); + } + if(!rdy_head[q] && rdy_tail[q]) { + kprintf("tail but no head: %s", (karg_t) when); + panic("scheduling error", NO_NUM); + } + if(rdy_tail[q] && rdy_tail[q]->p_nextready != NIL_PROC) { + kprintf("tail and tail->next not null; %s", (karg_t) when); + panic("scheduling error", NO_NUM); + } + for(xp = rdy_head[q]; xp != NIL_PROC; xp = xp->p_nextready) { + if (!xp->p_ready) { + kprintf("scheduling error: unready on runq: %s\n", (karg_t) when); + + panic("found unready process on run queue", NO_NUM); + } + if(xp->p_priority != q) { + kprintf("scheduling error: wrong priority: %s\n", (karg_t) when); + + panic("wrong priority", NO_NUM); + } + if(xp->p_found) { + kprintf("scheduling error: double scheduling: %s\n", (karg_t) when); + panic("proc more than once on scheduling queue", NO_NUM); + } + xp->p_found = 1; + if(xp->p_nextready == NIL_PROC && rdy_tail[q] != xp) { + kprintf("scheduling error: last element not tail: %s\n", (karg_t) when); + panic("scheduling error", NO_NUM); + } + if(l++ > PROCLIMIT) panic("loop in schedule queue?", NO_NUM); + } + } + + for (xp = BEG_PROC_ADDR; xp < END_PROC_ADDR; ++xp) { + if(isalivep(xp) && xp->p_ready && !xp->p_found) { + kprintf("scheduling error: ready not on queue: %s\n", (karg_t) when); + panic("ready proc not on scheduling queue", NO_NUM); + if(l++ > PROCLIMIT) { panic("loop in proc.t?", NO_NUM); } + } + } +} + /*==========================================================================* * do_debug * *==========================================================================*/