예제 #1
0
/*
 * thread_exit()
 *	Cause the current thread to cease executing.
 *
 * We remove ourself from the run queue, clear down some of the thread table
 * details and then jump into the middle of the task switching routine.
 * This switches our current state out without trying to save it first.
 */
void thread_exit(void)
{
    struct thread *t, **tprev;

    isr_disable();

    debug_set_lights(0x11);

    t = thread_list;
    tprev = &thread_list;

    while (t != (struct thread *)current_context) {
        tprev = &t->t_next;
        t = t->t_next;
    }

    *tprev = t->t_next;

    /*
     * We need to make sure that the memory used for this thread gets
     * restored to the heap.  We can't do that ourself of course as we're
     * using that memory now!
     */
    ((struct thread *)current_context)->t_next = idle_free;
    idle_free = (struct thread *)current_context;

    context_exit();
}
예제 #2
0
/* quit thread */
void thread_exit (int code)
{
  context_disable ();
  if (current_process)
    current_process->exit_code = code;
  context_exit ();
}