- xbt_os_thread_exit(NULL); /* We should provide return value in case other wants it */
-}
-
-static void xbt_ctx_thread_swap(xbt_context_t context)
-{
- DEBUG2("Swap context: '%s' -> '%s'", current_context->name, context->name);
- if ((current_context != maestro_context) && !context->iwannadie) {
- /* (0) it's not the scheduler and the process doesn't want to die, it just wants to yield */
-
- /* yield itself, resume the maestro */
- xbt_ctx_thread_suspend(context);
- } else {
- /* (1) the current process is the scheduler and the process doesn't want to die
- * <-> the maestro wants to schedule the process
- * -> the maestro schedules the process and waits
- *
- * (2) the current process is the scheduler and the process wants to die
- * <-> the maestro wants to kill the process (has called the function xbt_context_kill())
- * -> the maestro schedule the process and waits (xbt_os_sem_acquire(context->end))
- * -> if the process stops (xbt_context_stop())
- * -> the process resumes the maestro (xbt_os_sem_release(current_context->end)) and exit (xbt_os_thread_exit())
- * -> else the process call xbt_context_yield()
- * -> goto (3.1)
- *
- * (3) the current process is not the scheduler and the process wants to die
- * -> (3.1) if the current process is the process who wants to die
- * -> (resume not need) goto (4)
- * -> (3.2) else the current process is not the process who wants to die
- * <-> the current process wants to kill an other process
- * -> the current process resumes the process to die and waits
- * -> if the process to kill stops
- * -> it resumes the process who kill it and exit
- * -> else if the process to kill calls to xbt_context_yield()
- * -> goto (3.1)
- */
- /* schedule the process associated with this context */
- xbt_ctx_thread_resume(context);
-
- }
-
- /* (4) the current process wants to die */
- if (current_context->iwannadie)
- xbt_ctx_thread_stop(1);