-
- DEBUG2("Swap context: '%s' -> '%s'", simix_global->current_process->name, process->name);
- if ((simix_global->current_process != simix_global->maestro_process) && !process->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 */
- smx_ctx_thread_suspend(process);
- } 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 smx_context_kill())
- * -> the maestro schedule the process and waits (xbt_os_sem_acquire(context->end))
- * -> if the process stops (smx_context_stop())
- * -> the process resumes the maestro (xbt_os_sem_release(current_context->end)) and exit (xbt_os_thread_exit())
- * -> else the process call smx_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 smx_context_yield()
- * -> goto (3.1)
- */
- /* schedule the process associated with this context */
- smx_ctx_thread_resume(process);
-
- }
-
- /* (4) the current process wants to die */
- if (simix_global->current_process->iwannadie)
- smx_ctx_thread_stop(1);