From: Ben Gras Date: Sat, 3 Oct 2009 11:30:35 +0000 (+0000) Subject: - panic if there's no runnable process X-Git-Tag: v3.1.5~32 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zpipe.c?a=commitdiff_plain;h=fe35879325aed8a418c6a77ed9fbec3761cde9fb;p=minix.git - panic if there's no runnable process - more basic sanity check before recursive enter check (data segment) - try to jump to boot monitor instantly on recursive panic --- diff --git a/kernel/arch/i386/system.c b/kernel/arch/i386/system.c index b8bb73f22..9aef4ea2d 100644 --- a/kernel/arch/i386/system.c +++ b/kernel/arch/i386/system.c @@ -20,6 +20,11 @@ FORWARD _PROTOTYPE( void ser_debug, (int c)); +PUBLIC void arch_monitor(void) +{ + level0(monitor); +} + PUBLIC void arch_shutdown(int how) { /* Mask all interrupts, including the clock. */ @@ -68,7 +73,7 @@ PUBLIC void arch_shutdown(int how) arch_set_params(mybuffer, strlen(mybuffer)+1); } - level0(monitor); + arch_monitor(); } else { /* Reset the system by forcing a processor shutdown. First stop * the BIOS memory test by setting a soft reset flag. diff --git a/kernel/debug.h b/kernel/debug.h index e9de2a5ca..c170039d0 100644 --- a/kernel/debug.h +++ b/kernel/debug.h @@ -45,6 +45,9 @@ static int varname = 0; \ int mustunlock = 0; \ if(!intr_disabled()) { lock; mustunlock = 1; } \ + if(magictest != MAGICTEST) { \ + minix_panic(#varname " magictest failed", __LINE__); \ + } \ if(varname) { \ minix_panic(#varname " recursive enter", __LINE__); \ } \ diff --git a/kernel/glo.h b/kernel/glo.h index 208818353..7c340560c 100755 --- a/kernel/glo.h +++ b/kernel/glo.h @@ -58,6 +58,8 @@ EXTERN time_t boottime; EXTERN char params_buffer[512]; /* boot monitor parameters */ EXTERN int minix_panicing; EXTERN int locklevel; +#define MAGICTEST 0xC0FFEE23 +EXTERN u32_t magictest; /* global magic number */ #if DEBUG_TRACE EXTERN int verboseflags; diff --git a/kernel/main.c b/kernel/main.c index 885dddb94..c867544ec 100755 --- a/kernel/main.c +++ b/kernel/main.c @@ -40,6 +40,9 @@ PUBLIC void main() /* Architecture-dependent initialization. */ arch_init(); + + /* Global value to test segment sanity. */ + magictest = MAGICTEST; /* Clear the process table. Anounce each slot as empty and set up mappings * for proc_addr() and proc_nr() macros. Do the same for the table with diff --git a/kernel/proc.c b/kernel/proc.c index 5ef4555e9..5d6afee47 100755 --- a/kernel/proc.c +++ b/kernel/proc.c @@ -1327,6 +1327,7 @@ PRIVATE void pick_proc() bill_ptr = rp; /* bill for system time */ NOREC_RETURN(pick, ); } + minix_panic("no runnable processes", NO_NUM); } /*===========================================================================* diff --git a/kernel/proto.h b/kernel/proto.h index 3f8cfa1d9..cfdcdf87e 100755 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -149,6 +149,7 @@ _PROTOTYPE( void idle_task, (void) ); _PROTOTYPE( void arch_init, (void) ); _PROTOTYPE( void ser_putc, (char) ); _PROTOTYPE( void arch_shutdown, (int) ); +_PROTOTYPE( void arch_monitor, (void) ); _PROTOTYPE( void arch_get_aout_headers, (int i, struct exec *h) ); _PROTOTYPE( void restart, (void) ); _PROTOTYPE( void read_tsc, (unsigned long *high, unsigned long *low) ); diff --git a/kernel/utility.c b/kernel/utility.c index 0e3ac6ca2..fa31cf3fe 100755 --- a/kernel/utility.c +++ b/kernel/utility.c @@ -37,7 +37,9 @@ char *mess; int nr; { /* The system has run aground of a fatal kernel error. Terminate execution. */ -if (!minix_panicing++) { +if (minix_panicing++) { + arch_monitor(); +} if (mess != NULL) { kprintf("kernel panic: %s", mess); @@ -48,7 +50,6 @@ if (!minix_panicing++) { kprintf("kernel: "); util_stacktrace(); -} /* Abort MINIX. */ minix_shutdown(NULL);