- self = current_context;
- DEBUG2("[%p] **** Locking ctx %p ****", self, context);
- xbt_os_mutex_lock(context->mutex);
- DEBUG1("[%p] **** Updating current_context ****", self);
- current_context = context;
- DEBUG1("[%p] **** Releasing the prisonner ****", self);
- xbt_os_cond_signal(context->cond);
- DEBUG3("[%p] **** Going to jail on individual %p/%p ****", self,
- context->cond, context->mutex);
- xbt_os_cond_wait(context->cond, context->mutex);
- DEBUG2("[%p] **** Unlocking individual %p ****", self, context->mutex);
- xbt_os_mutex_unlock(context->mutex);
- DEBUG1("[%p] **** Updating current_context ****", self);
- current_context = self;
-
-#else /* use SUSv2 contexts */
+
+ 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 */
+ yield(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;
+ }
+
+#else /* use SUSv2 contexts */