Index: kern/sched_ule.c =================================================================== RCS file: /home/ncvs/src/sys/kern/sched_ule.c,v retrieving revision 1.11 diff -u -r1.11 sched_ule.c --- kern/sched_ule.c 17 Feb 2003 09:55:09 -0000 1.11 +++ kern/sched_ule.c 18 Feb 2003 16:11:03 -0000 @@ -54,11 +54,13 @@ static fixpt_t ccpu = 0.95122942450071400909 * FSCALE; /* exp(-1/20) */ SYSCTL_INT(_kern, OID_AUTO, ccpu, CTLFLAG_RD, &ccpu, 0, ""); +static int strict_resched = 1; +SYSCTL_INT(_kern, OID_AUTO, strict_resched, CTLFLAG_RW, + &strict_resched, 0, "Conditional context switching."); + static void sched_setup(void *dummy); SYSINIT(sched_setup, SI_SUB_RUN_QUEUE, SI_ORDER_FIRST, sched_setup, NULL) -#define SCHED_STRICT_RESCHED 1 - /* * These datastructures are allocated within their parent datastructure but * are scheduler specific. @@ -170,16 +172,6 @@ #define SCHED_PRI_COMP(slice) (((slice) / 5) * 2) /* 40% */ /* - * This macro determines whether or not the kse belongs on the current or - * next run queue. - * - * XXX nice value should effect how interactive a kg is. - */ -#define SCHED_CURR(kg) (((kg)->kg_slptime > (kg)->kg_runtime && \ - sched_slp_ratio((kg)->kg_slptime, (kg)->kg_runtime) > 4) || \ - (kg)->kg_pri_class != PRI_TIMESHARE) - -/* * Cpu percentage computation macros and defines. * * SCHED_CPU_TIME: Number of seconds to average the cpu usage across. @@ -515,11 +507,11 @@ mtx_assert(&sched_lock, MA_OWNED); td->td_kse->ke_oncpu = PCPU_GET(cpuid); -#if SCHED_STRICT_RESCHED - if (td->td_ksegrp->kg_pri_class == PRI_TIMESHARE && - td->td_priority != td->td_ksegrp->kg_user_pri) - curthread->td_flags |= TDF_NEEDRESCHED; -#endif + if (strict_resched) { + if (td->td_ksegrp->kg_pri_class == PRI_TIMESHARE && + td->td_priority != td->td_ksegrp->kg_user_pri) + curthread->td_flags |= TDF_NEEDRESCHED; + } } void @@ -582,10 +574,10 @@ } #endif setrunqueue(td); -#if SCHED_STRICT_RESCHED - if (td->td_priority < curthread->td_priority) - curthread->td_flags |= TDF_NEEDRESCHED; -#endif + if (strict_resched) { + if (td->td_priority < curthread->td_priority) + curthread->td_flags |= TDF_NEEDRESCHED; + } } /* @@ -653,10 +645,8 @@ sched_clock(struct thread *td) { struct kse *ke; -#if SCHED_STRICT_RESCHED struct kse *nke; struct kseq *kseq; -#endif struct ksegrp *kg; @@ -680,14 +670,16 @@ * Check for a higher priority task on the run queue. This can happen * on SMP if another processor woke up a process on our runq. */ -#if SCHED_STRICT_RESCHED - kseq = KSEQ_SELF(); - nke = runq_choose(kseq->ksq_curr); - if (nke && nke->ke_thread && - nke->ke_thread->td_priority < td->td_priority) - td->td_flags |= TDF_NEEDRESCHED; -#endif + if (strict_resched) { + kseq = KSEQ_SELF(); + nke = runq_choose(kseq->ksq_curr); + + if (nke && nke->ke_thread && + nke->ke_thread->td_priority < td->td_priority) + td->td_flags |= TDF_NEEDRESCHED; + } + /* * We used a tick charge it to the ksegrp so that we can compute our * "interactivity". Index: sys/sched.h =================================================================== RCS file: /home/ncvs/src/sys/sys/sched.h,v retrieving revision 1.3 diff -u -r1.3 sched.h --- sys/sched.h 21 Nov 2002 09:30:55 -0000 1.3 +++ sys/sched.h 18 Feb 2003 16:11:00 -0000 @@ -81,4 +81,14 @@ extern struct p_sched *proc0_sched; extern struct td_sched *thread0_sched; +/* + * This macro determines whether or not the kse belongs on the current or + * next run queue. + * + * XXX nice value should effect how interactive a kg is. + */ +#define SCHED_CURR(kg) (((kg)->kg_slptime > (kg)->kg_runtime && \ + sched_slp_ratio((kg)->kg_slptime, (kg)->kg_runtime) > 4) || \ + (kg)->kg_pri_class != PRI_TIMESHARE) + #endif /* !_SYS_SCHED_H_ */