* Do any thread specific cleanups that may be needed in wait() * called with Giant, proc and schedlock not held. */
| 959 | * called with Giant, proc and schedlock not held. |
| 960 | */ |
| 961 | void |
| 962 | thread_wait(struct proc *p) |
| 963 | { |
| 964 | struct thread *td; |
| 965 | |
| 966 | mtx_assert(&Giant, MA_NOTOWNED); |
| 967 | KASSERT(p->p_numthreads == 1, ("multiple threads in thread_wait()")); |
| 968 | KASSERT(p->p_exitthreads == 0, ("p_exitthreads leaking")); |
| 969 | td = FIRST_THREAD_IN_PROC(p); |
| 970 | /* Lock the last thread so we spin until it exits cpu_throw(). */ |
| 971 | thread_lock(td); |
| 972 | thread_unlock(td); |
| 973 | lock_profile_thread_exit(td); |
| 974 | cpuset_rel(td->td_cpuset); |
| 975 | td->td_cpuset = NULL; |
| 976 | cpu_thread_clean(td); |
| 977 | thread_cow_free(td); |
| 978 | callout_drain(&td->td_slpcallout); |
| 979 | thread_reap(); /* check for zombie threads etc. */ |
| 980 | } |
| 981 | |
| 982 | /* |
| 983 | * Link a thread to a process. |
no test coverage detected