diff options
author | julian <julian@FreeBSD.org> | 2007-10-27 00:54:16 +0000 |
---|---|---|
committer | julian <julian@FreeBSD.org> | 2007-10-27 00:54:16 +0000 |
commit | 93719028adcc33c0c017cc740790afc39121ae33 (patch) | |
tree | a5c8b476949bc53627b25b51b1ef91b398b7529a /sys/kern/kern_kthread.c | |
parent | bc607610fb3b864a235d206b9efa2af5ad7d0cc8 (diff) | |
download | FreeBSD-src-93719028adcc33c0c017cc740790afc39121ae33.zip FreeBSD-src-93719028adcc33c0c017cc740790afc39121ae33.tar.gz |
Add support for the pre-exisiting module shutdoen handshake.
Fix some comments.
Diffstat (limited to 'sys/kern/kern_kthread.c')
-rw-r--r-- | sys/kern/kern_kthread.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/sys/kern/kern_kthread.c b/sys/kern/kern_kthread.c index 03d404b..532b3c2 100644 --- a/sys/kern/kern_kthread.c +++ b/sys/kern/kern_kthread.c @@ -235,7 +235,6 @@ kthread_start(udata) * arg is the parameter to pass to function on first startup. * newtdp is the return value pointing to the thread's struct thread. * ** XXX fix this --> flags are flags to fork1 (in unistd.h) - * ** XXX are any used? * fmt and following will be *printf'd into (*newtd)->td_name (for ps, etc.). */ int @@ -250,17 +249,15 @@ kthread_add(void (*func)(void *), void *arg, struct proc *p, panic("kthread_add called too soon"); error = 0; + /* If no process supplied, put it on proc0 */ if (p == NULL) { p = &proc0; oldtd = &thread0; } else { - if (p == &proc0) - oldtd = &thread0; - else - oldtd = FIRST_THREAD_IN_PROC(p); + oldtd = FIRST_THREAD_IN_PROC(p); } - /* Initialize our td */ + /* Initialize our new td */ newtd = thread_alloc(); if (newtd == NULL) return (ENOMEM); @@ -320,12 +317,14 @@ kthread_add(void (*func)(void *), void *arg, struct proc *p, void kthread_exit(void) { + /* a module may be waiting for us to exit */ + wakeup(curthread); /* * We could rely on thread_exit to call exit1() but * there is extra work that needs to be done */ if (curthread->td_proc->p_numthreads == 1) - kproc_exit(0); + kproc_exit(0); /* never returns */ thread_exit(); } |