diff options
author | jeff <jeff@FreeBSD.org> | 2004-02-01 05:37:36 +0000 |
---|---|---|
committer | jeff <jeff@FreeBSD.org> | 2004-02-01 05:37:36 +0000 |
commit | 75249cf38e5ac423561abeb1906852c0579f9e3c (patch) | |
tree | 4ac19d31d094e390d649c64b09b8976e2902797b /sys | |
parent | 6b653d4085f2f05070dfb82376f97b539019c66d (diff) | |
download | FreeBSD-src-75249cf38e5ac423561abeb1906852c0579f9e3c.zip FreeBSD-src-75249cf38e5ac423561abeb1906852c0579f9e3c.tar.gz |
- Revert rev 1.240 we no longer need a kthread for loadav().
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/kern_synch.c | 43 |
1 files changed, 12 insertions, 31 deletions
diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index cf691bf..9ffe5a9 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -49,7 +49,6 @@ __FBSDID("$FreeBSD$"); #include <sys/condvar.h> #include <sys/kernel.h> #include <sys/ktr.h> -#include <sys/kthread.h> #include <sys/lock.h> #include <sys/mutex.h> #include <sys/proc.h> @@ -77,6 +76,7 @@ SYSINIT(synch_setup, SI_SUB_KICK_SCHEDULER, SI_ORDER_FIRST, synch_setup, NULL) int hogticks; int lbolt; +static struct callout loadav_callout; static struct callout lbolt_callout; struct loadavg averunnable = @@ -96,8 +96,7 @@ static int fscale __unused = FSCALE; SYSCTL_INT(_kern, OID_AUTO, fscale, CTLFLAG_RD, 0, FSCALE, ""); static void endtsleep(void *); -static void loadav(void); -static void loadav_thread(void *dummy); +static void loadav(void *arg); static void lboltcb(void *arg); /* @@ -582,7 +581,7 @@ setrunnable(struct thread *td) * Completely Bogus.. only works with 1:1 (but compiles ok now :-) */ static void -loadav(void) +loadav(void *arg) { int i, nrun; struct loadavg *avg; @@ -593,31 +592,14 @@ loadav(void) for (i = 0; i < 3; i++) avg->ldavg[i] = (cexp[i] * avg->ldavg[i] + nrun * FSCALE * (FSCALE - cexp[i])) >> FSHIFT; -} -/* - * Main loop for a kthread that executes loadav() periodically. - */ -static void -loadav_thread(void *dummy) -{ - struct proc *p; - int nowake; - - p = curthread->td_proc; - PROC_LOCK(p); - p->p_flag |= P_NOLOAD; - PROC_UNLOCK(p); - for (;;) { - loadav(); - /* - * Schedule the next update to occur after 5 seconds, but - * add a random variation to avoid synchronisation with - * processes that run at regular intervals. - */ - tsleep(&nowake, curthread->td_priority, "-", hz * 4 + - (int)(random() % (hz * 2 + 1))); - } + /* + * Schedule the next update to occur after 5 seconds, but add a + * random variation to avoid synchronisation with processes that + * run at regular intervals. + */ + callout_reset(&loadav_callout, hz * 4 + (int)(random() % (hz * 2 + 1)), + loadav, NULL); } static void @@ -632,13 +614,12 @@ static void synch_setup(dummy) void *dummy; { + callout_init(&loadav_callout, 0); callout_init(&lbolt_callout, CALLOUT_MPSAFE); /* Kick off timeout driven events by calling first time. */ + loadav(NULL); lboltcb(NULL); - - /* Kick off loadav kernel process. */ - kthread_create(loadav_thread, NULL, NULL, 0, 0, "loadav"); } /* |