diff options
| author | Julian Elischer <julian@FreeBSD.org> | 2004-10-05 20:39:26 +0000 |
|---|---|---|
| committer | Julian Elischer <julian@FreeBSD.org> | 2004-10-05 20:39:26 +0000 |
| commit | e5bedcef9217a9aa27bd9aaeca0a570e87081cc3 (patch) | |
| tree | 6b0419004c872b1efc51b51f78180afce33fd342 /sys/kern/kern_thread.c | |
| parent | 6299d42bf4ce3f2d0bd0592ace735159ff9c392a (diff) | |
Notes
Diffstat (limited to 'sys/kern/kern_thread.c')
| -rw-r--r-- | sys/kern/kern_thread.c | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c index b8535209f047..28dcb137053b 100644 --- a/sys/kern/kern_thread.c +++ b/sys/kern/kern_thread.c @@ -709,6 +709,29 @@ thread_link(struct thread *td, struct ksegrp *kg) } /* + * Convert a process with one thread to an unthreaded process. + * Called from: + * thread_single(exit) (called from execve and exit) + * kse_exit() XXX may need cleaning up wrt KSE stuff + */ +void +thread_unthread(struct thread *td) +{ + struct proc *p = td->td_proc; + + KASSERT((p->p_numthreads == 1), ("Unthreading with >1 threads")); + upcall_remove(td); + p->p_flag &= ~(P_SA|P_HADTHREADS); + td->td_mailbox = NULL; + td->td_pflags &= ~(TDP_SA | TDP_CAN_UNBIND); + if (td->td_standin != NULL) { + thread_stash(td->td_standin); + td->td_standin = NULL; + } + sched_set_concurrency(td->td_ksegrp, 1); +} + +/* * Called from: * thread_exit() */ @@ -835,21 +858,11 @@ thread_single(int force_exit) * we try our utmost to revert to being a non-threaded * process. */ - upcall_remove(td); - p->p_flag &= ~(P_SA|P_HADTHREADS); - td->td_mailbox = NULL; - td->td_pflags &= ~(TDP_SA | TDP_CAN_UNBIND); - p->p_flag &= ~(P_STOPPED_SINGLE | P_SINGLE_EXIT); p->p_singlethread = NULL; - if (td->td_standin != NULL) { - thread_stash(td->td_standin); - td->td_standin = NULL; - } - sched_set_concurrency(td->td_ksegrp, 1); - mtx_unlock_spin(&sched_lock); - } else { - mtx_unlock_spin(&sched_lock); + p->p_flag &= ~(P_STOPPED_SINGLE | P_SINGLE_EXIT); + thread_unthread(td); } + mtx_unlock_spin(&sched_lock); return (0); } @@ -1004,7 +1017,6 @@ thread_unsuspend(struct proc *p) /* * End the single threading mode.. - * Part of this is duplicated in thread-single in the SINGLE_EXIT case. */ void thread_single_end(void) |
