Exemplo n.º 1
0
/*
 * Destroy a thread.
 *
 * This function cannot be called in the victim thread's own context.
 * Nor can it be called on a running thread.
 *
 * (Freeing the stack you're actually using to run is ... inadvisable.)
 */
static
void
thread_destroy(struct thread *thread)
{
	KASSERT(thread != curthread);
	KASSERT(thread->t_state != S_RUN);

	/*
	 * If you add things to struct thread, be sure to clean them up
	 * either here or in thread_exit(). (And not both...)
	 */

	/* Thread subsystem fields */
	KASSERT(thread->t_proc == NULL);
	if (thread->t_stack != NULL) {
		kfree(thread->t_stack);
	}
	threadlistnode_cleanup(&thread->t_listnode);
	thread_machdep_cleanup(&thread->t_machdep);

	/* sheer paranoia */
	thread->t_wchan_name = "DESTROYED";

	kfree(thread->t_name);
	kfree(thread);
}
/*
 * Destroy a thread.
 *
 * This function cannot be called in the victim thread's own context.
 * Nor can it be called on a running thread.
 *
 * (Freeing the stack you're actually using to run is ... inadvisable.)
 *
 * Thread destroy should finish the process of cleaning up a thread started by
 * thread_exit.
 */
static
void
thread_destroy(struct thread *thread)
{
    KASSERT(thread != curthread);
    KASSERT(thread->t_state != S_RUN);

    /* Thread subsystem fields */
    KASSERT(thread->t_proc == NULL);
    if (thread->t_stack != NULL) {
        kfree(thread->t_stack);
    }
    threadlistnode_cleanup(&thread->t_listnode);
    thread_machdep_cleanup(&thread->t_machdep);

    /* sheer paranoia */
    thread->t_wchan_name = "DESTROYED";

    kfree(thread);
}