From 769e0f974d8929599ba599ac496510fffc90ff34 Mon Sep 17 00:00:00 2001 From: jasone Date: Thu, 7 Sep 2000 01:33:02 +0000 Subject: Major update to the way synchronization is done in the kernel. Highlights include: * Mutual exclusion is used instead of spl*(). See mutex(9). (Note: The alpha port is still in transition and currently uses both.) * Per-CPU idle processes. * Interrupts are run in their own separate kernel threads and can be preempted (i386 only). Partially contributed by: BSDi (BSD/OS) Submissions by (at least): cp, dfr, dillon, grog, jake, jhb, sheldonh --- sys/kern/kern_kthread.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'sys/kern/kern_kthread.c') diff --git a/sys/kern/kern_kthread.c b/sys/kern/kern_kthread.c index 6373750..e684b78 100644 --- a/sys/kern/kern_kthread.c +++ b/sys/kern/kern_kthread.c @@ -52,24 +52,33 @@ kproc_start(udata) int error; error = kthread_create((void (*)(void *))kp->func, NULL, - kp->global_procpp, kp->arg0); + kp->global_procpp, 0, kp->arg0); if (error) panic("kproc_start: %s: error %d", kp->arg0, error); } /* - * Create a kernel process/thread/whatever. It shares it's address space + * Create a kernel process/thread/whatever. It shares its address space * with proc0 - ie: kernel only. + * + * func is the function to start. + * arg is the parameter to pass to function on first startup. + * newpp is the return value pointing to the thread's struct proc. + * flags are flags to fork1 (in unistd.h) + * fmt and following will be *printf'd into (*newpp)->p_comm (for ps, etc.). */ int kthread_create(void (*func)(void *), void *arg, - struct proc **newpp, const char *fmt, ...) + struct proc **newpp, int flags, const char *fmt, ...) { int error; va_list ap; struct proc *p2; - error = fork1(&proc0, RFMEM | RFFDG | RFPROC, &p2); + if (!proc0.p_stats /* || proc0.p_stats->p_start.tv_sec == 0 */) + panic("kthread_create called too soon"); + + error = fork1(&proc0, RFMEM | RFFDG | RFPROC | flags, &p2); if (error) return error; -- cgit v1.1