diff options
Diffstat (limited to 'sys/kern/kern_thread.c')
-rw-r--r-- | sys/kern/kern_thread.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c index 784d45b..5f03369 100644 --- a/sys/kern/kern_thread.c +++ b/sys/kern/kern_thread.c @@ -1198,17 +1198,7 @@ thread_exit(void) * all this stuff. */ if (p->p_numthreads > 1) { - /* - * Unlink this thread from its proc and the kseg. - * In keeping with the other structs we probably should - * have a thread_unlink() that does some of this but it - * would only be called from here (I think) so it would - * be a waste. (might be useful for proc_fini() as well.) - */ - TAILQ_REMOVE(&p->p_threads, td, td_plist); - p->p_numthreads--; - TAILQ_REMOVE(&kg->kg_threads, td, td_kglist); - kg->kg_numthreads--; + thread_unlink(td); if (p->p_maxthrwaits) wakeup(&p->p_numthreads); /* @@ -1315,6 +1305,19 @@ thread_link(struct thread *td, struct ksegrp *kg) kg->kg_numthreads++; } +void +thread_unlink(struct thread *td) +{ + struct proc *p = td->td_proc; + struct ksegrp *kg = td->td_ksegrp; + + TAILQ_REMOVE(&p->p_threads, td, td_plist); + p->p_numthreads--; + TAILQ_REMOVE(&kg->kg_threads, td, td_kglist); + kg->kg_numthreads--; + /* could clear a few other things here */ +} + /* * Purge a ksegrp resource. When a ksegrp is preparing to * exit, it calls this function. |