Date: Mon, 17 Nov 2003 07:55:03 -0800 (PST) From: John Baldwin <jhb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 42666 for review Message-ID: <200311171555.hAHFt3tV025116@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=42666 Change 42666 by jhb@jhb_laptop on 2003/11/17 07:54:49 Move schedcpu() off into is own kthread to work around locking problems with calling this from softclock. Affected files ... .. //depot/projects/smpng/sys/kern/sched_4bsd.c#18 edit Differences ... ==== //depot/projects/smpng/sys/kern/sched_4bsd.c#18 (text+ko) ==== @@ -80,11 +80,11 @@ static int sched_quantum; /* Roundrobin scheduling quantum in ticks. */ #define SCHED_QUANTUM (hz / 10) /* Default sched quantum */ -static struct callout schedcpu_callout; static struct callout roundrobin_callout; static void roundrobin(void *arg); static void schedcpu(void *arg); +static void schedcpu_thread(void *dummy); static void sched_setup(void *dummy); static void maybe_resched(struct thread *td); static void updatepri(struct ksegrp *kg); @@ -348,7 +348,20 @@ mtx_unlock_spin(&sched_lock); } /* end of process loop */ sx_sunlock(&allproc_lock); - callout_reset(&schedcpu_callout, hz, schedcpu, NULL); +} + +/* + * Main loop for a kthread that executes schedcpu once a second. + */ +static void +schedcpu_thread(void *dummy) +{ + int nowake; + + for (;;) { + schedcpu(); + tsleep(&nowake, curthread->td_priority, "-", hz); + } } /* @@ -407,12 +420,13 @@ sched_quantum = SCHED_QUANTUM; hogticks = 2 * sched_quantum; - callout_init(&schedcpu_callout, CALLOUT_MPSAFE); callout_init(&roundrobin_callout, 0); /* Kick off timeout driven events by calling first time. */ roundrobin(NULL); - schedcpu(NULL); + + /* Kick off schedcpu kernel process. */ + kthread_create(schedcpu_thread, NULL, NULL, 0, 0, "schedcpu"); } /* External interfaces start here */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200311171555.hAHFt3tV025116>