+
+/**
+ * Calling this function makes the process process to yield. The process
+ * that scheduled it returns from __SIMIX_process_schedule as if nothing
+ * had happened.
+ *
+ * Only the processes can call this function, giving back the control
+ * to the maestro
+ */
+void __SIMIX_process_yield(void)
+{
+ DEBUG1("Yield process '%s'", simix_global->current_process->name);
+ xbt_assert0((simix_global->current_process != simix_global->maestro_process),
+ "You are not supposed to run this function here!");
+
+ SIMIX_context_suspend(simix_global->current_process->context);
+
+ if (simix_global->current_process->iwannadie)
+ SIMIX_context_stop(simix_global->current_process->context);
+}
+
+void __SIMIX_process_schedule(smx_process_t new_process)
+{
+ DEBUG1("Scheduling context: '%s'", new_process->name);
+
+ /* save the current process */
+ smx_process_t old_process = simix_global->current_process;
+
+ /* update the current process */
+ simix_global->current_process = new_process;
+
+ /* schedule the context */
+ SIMIX_context_resume(old_process->context, new_process->context);
+
+ /* restore the current process to the previously saved process */
+ simix_global->current_process = old_process;
+}