From: Ben Gras Date: Sun, 7 Jun 2009 16:25:37 +0000 (+0000) Subject: minor cleanup X-Git-Tag: v3.1.4~10 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/style.css?a=commitdiff_plain;h=e2a7535c5565c3f31f53ec1db1afe299c1322aec;p=minix.git minor cleanup --- diff --git a/kernel/debug.h b/kernel/debug.h index c274e5be2..374f940f8 100644 --- a/kernel/debug.h +++ b/kernel/debug.h @@ -28,7 +28,7 @@ #define DEBUG_VMASSERT 0 #define DEBUG_SCHED_CHECK 0 #define DEBUG_STACK_CHECK 0 -#define DEBUG_TRACE 0 +#define DEBUG_TRACE 1 #if DEBUG_TRACE diff --git a/kernel/proc.c b/kernel/proc.c index b17ea091e..8df75c1e6 100755 --- a/kernel/proc.c +++ b/kernel/proc.c @@ -8,8 +8,6 @@ * * lock_notify: notify a process of a system event * lock_send: send a message to a process - * lock_enqueue: put a process on one of the scheduling queues - * lock_dequeue: remove a process from the scheduling queues * * Changes: * Aug 19, 2005 rewrote scheduling code (Jorrit N. Herder) @@ -107,15 +105,6 @@ PRIVATE int QueueMess(endpoint_t ep, vir_bytes msg_lin, struct proc *dst) dst->p_delivermsg.m_source = ep; dst->p_misc_flags |= MF_DELIVERMSG; -#if 0 - if(iskernelp(dst) || ptproc == dst) { - printf("instant delivery to %d\n", dst->p_endpoint); - delivermsg(dst); - } else { - printf("queued delivery to %d\n", dst->p_endpoint); - } -#endif - NOREC_RETURN(queuemess, OK); } @@ -153,6 +142,9 @@ PUBLIC void schedcheck(void) } TRACE(VF_SCHEDULING, printf("starting %s / %d\n", proc_ptr->p_name, proc_ptr->p_endpoint);); +#if DEBUG_TRACE + proc_ptr->p_schedules++; +#endif NOREC_RETURN(schedch, ); } @@ -1269,37 +1261,6 @@ message *m_ptr; /* pointer to message buffer */ return(result); } -/*===========================================================================* - * lock_enqueue * - *===========================================================================*/ -PUBLIC void lock_enqueue(rp) -struct proc *rp; /* this process is now runnable */ -{ -/* Safe gateway to enqueue() for tasks. */ - lock; - enqueue(rp); - unlock; -} - -/*===========================================================================* - * lock_dequeue * - *===========================================================================*/ -PUBLIC void lock_dequeue(rp) -struct proc *rp; /* this process is no longer runnable */ -{ -/* Safe gateway to dequeue() for tasks. */ - if (k_reenter >= 0) { - /* We're in an exception or interrupt, so don't lock (and ... - * don't unlock). - */ - dequeue(rp); - } else { - lock; - dequeue(rp); - unlock; - } -} - /*===========================================================================* * endpoint_lookup * *===========================================================================*/ diff --git a/kernel/proc.h b/kernel/proc.h index 48de9cf3f..006396ee0 100755 --- a/kernel/proc.h +++ b/kernel/proc.h @@ -94,6 +94,10 @@ struct proc { #define PMAGIC 0xC0FFEE1 int p_magic; /* check validity of proc pointers */ #endif + +#if DEBUG_TRACE + int p_schedules; +#endif }; /* Bits for the runtime flags. A process is runnable iff p_rts_flags == 0. */ @@ -161,8 +165,11 @@ struct proc { /* Set flags to this value. */ #define RTS_LOCK_SETFLAGS(rp, f) \ do { \ - if(!(rp)->p_rts_flags && (f)) { lock_dequeue(rp); } \ - (rp)->p_rts_flags = (f); \ + int u = 0; \ + if(!intr_disabled()) { u = 1; lock; } \ + if(!(rp)->p_rts_flags && (f)) { dequeue(rp); } \ + (rp)->p_rts_flags = (f); \ + if(u) { unlock; } \ } while(0) /* Misc flags */ diff --git a/kernel/proto.h b/kernel/proto.h index 229de982a..970d84015 100755 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -34,8 +34,6 @@ _PROTOTYPE( int sys_call, (int call_nr, int src_dst, _PROTOTYPE( void sys_call_restart, (struct proc *caller) ); _PROTOTYPE( int lock_notify, (int src, int dst) ); _PROTOTYPE( int lock_send, (int dst, message *m_ptr) ); -_PROTOTYPE( void lock_enqueue, (struct proc *rp) ); -_PROTOTYPE( void lock_dequeue, (struct proc *rp) ); _PROTOTYPE( void enqueue, (struct proc *rp) ); _PROTOTYPE( void dequeue, (struct proc *rp) ); _PROTOTYPE( void balance_queues, (struct timer *tp) ); diff --git a/kernel/system.c b/kernel/system.c index 0093bce10..48adc9a3f 100755 --- a/kernel/system.c +++ b/kernel/system.c @@ -92,6 +92,7 @@ PUBLIC void sys_task() #if 1 { + struct proc *stp; static int prevu; int u, dt; u = get_uptime(); @@ -113,6 +114,18 @@ PUBLIC void sys_task() npagefaults = 0; vmreqs = 0; prevu = u; +#if DEBUG_TRACE + for (stp = BEG_PROC_ADDR; stp < END_PROC_ADDR; stp++) { + int ps = PERSEC(stp->p_schedules); + if(isemptyp(stp)) + continue; + if(ps > 10) { + printf("%s %d ", stp->p_name, ps); + stp->p_schedules = 0; + } + } + printf("\n"); +#endif } } #endif