-thread_doreap(
- register thread_t thread)
-{
- thread_act_t thr_act;
- struct ipc_port *pool_port;
-
-
- thr_act = thread_lock_act(thread);
- assert(thr_act && thr_act->thread == thread);
-
- act_locked_act_reference(thr_act);
- pool_port = thr_act->pool_port;
-
- /*
- * Replace `act_unlock_thread()' with individual
- * calls. (`act_detach()' can change fields used
- * to determine which locks are held, confusing
- * `act_unlock_thread()'.)
- */
- rpc_unlock(thread);
- if (pool_port != IP_NULL)
- ip_unlock(pool_port);
- act_unlock(thr_act);
-
- /* Remove the reference held by a rooted thread */
- if (pool_port == IP_NULL)
- act_deallocate(thr_act);
-
- /* Remove the reference held by the thread: */
- act_deallocate(thr_act);
-}
-
-static thread_call_data_t thread_reaper_call_data;
-
-/*
- * reaper_thread:
- *
- * This kernel thread runs forever looking for threads to destroy
- * (when they request that they be destroyed, of course).
- *
- * The reaper thread will disappear in the next revision of thread
- * control when it's function will be moved into thread_dispatch.
- */
-static void
-_thread_reaper(
- thread_call_param_t p0,
- thread_call_param_t p1)
-{
- register thread_t thread;
- spl_t s;
-
- s = splsched();
- simple_lock(&reaper_lock);
-
- while ((thread = (thread_t) dequeue_head(&reaper_queue)) != THREAD_NULL) {
- simple_unlock(&reaper_lock);
-
- /*
- * wait for run bit to clear
- */
- thread_lock(thread);
- if (thread->state & TH_RUN)
- panic("thread reaper: TH_RUN");
- thread_unlock(thread);
- splx(s);
-
- thread_doreap(thread);
-
- s = splsched();
- simple_lock(&reaper_lock);
- }
-
- simple_unlock(&reaper_lock);
- splx(s);
-}
-
-void
-thread_reaper(void)