static struct schedee *thread_process(struct schedee *prev, struct schedee *next) { struct thread *next_t, *prev_t; next_t = mcast_out(next, struct thread, schedee); prev_t = mcast_out(prev, struct thread, schedee); thread_set_current(next_t); /* Threads context switch */ if (prev != next) { thread_context_switch(prev_t, next_t); } ipl_enable(); if (!prev_t->siglock) { thread_signal_handle(); } return &thread_self()->schedee; }
/// Schedule Threads from the scheduler until one e /// If <result> non-NULL, store the Worker's exit value there. /// This routine is only to be called if the current Worker /// is the master Worker (the one returned by convert_to_master()). /// @return the exited Worker, or NULL if scheduler is done Worker * TaskingScheduler::thread_wait( void **result ) { CHECK( current_thread == master ) << "only meant to be called by system Worker"; Worker * next = nextCoroutine( false ); if (next == NULL) { // no user threads remain return NULL; } else { current_thread = next; Worker * died = (Worker *) thread_context_switch( master, next, NULL); // At the moment, we only return from a Worker in the case of death. if (result != NULL) { void *retval = (void *)died->next; *result = retval; } return died; } }