- self = current_context;
-
- if (is_main_thread()) {
- /* the main thread has called this function
- * - update the current context
- * - signal the condition of the process to run
- * - wait on its condition
- * - restore thr current contex
- */
-
- xbt_os_mutex_lock(master_mutex);
- xbt_os_mutex_lock(context->mutex);
-
- /* update the current context */
- current_context = context;
- xbt_os_cond_signal(context->cond);
- xbt_os_mutex_unlock(context->mutex);
-
- xbt_os_cond_wait(master_cond, master_mutex);
- xbt_os_mutex_unlock(master_mutex);
- /* retore the current context */
- current_context = self;
-
- } else {
- /* a java thread has called this function
- * - update the current context
- * - signal the condition of the main thread
- * - wait on its condition
- * - restore thr current contex
- */
-
- xbt_os_mutex_lock(master_mutex);
- xbt_os_mutex_lock(context->mutex);
- /* update the current context */
- current_context = context;
- xbt_os_cond_signal(master_cond);
- xbt_os_mutex_unlock(master_mutex);
- xbt_os_cond_wait(context->cond, context->mutex);
- xbt_os_mutex_unlock(context->mutex);
- /* retore the current context */
- current_context = self;
- }
+ if(current_context != init_context && !context->iwannadie)
+ {/* it's a process and it doesn't wants to die (xbt_context_yield()) */
+
+ /* save the current context */
+ xbt_context_t self = current_context;
+
+ /* update the current context to this context */
+ current_context = context;
+
+ /* yield itself */
+ unschedule(context);
+
+ /* restore the current context to the previously saved context */
+ current_context = self;
+ }
+ else
+ { /* maestro wants to schedule a process or a process wants to die (xbt_context_schedule() or xbt_context_kill())*/
+
+ /* save the current context */
+ xbt_context_t self = current_context;
+
+ /* update the current context */
+ current_context = context;
+
+ /* schedule the process associated with this context */
+ schedule(context);
+
+ /* restore the current context to the previously saved context */
+ current_context = self;
+ }