- smx_context_t context = process->context;
- SIMIX_context_set_current((smx_context_t) context);
- int rv;
- rv = swapcontext(&((smx_ctx_sysv_t)context)->old_uc, &((smx_ctx_sysv_t) context)->uc);
- SIMIX_context_set_current((smx_context_t) maestro_context);
+#ifdef CONTEXT_THREADS
+ /* determine the next context */
+ smx_context_t next_context;
+ unsigned long int i = __sync_fetch_and_add(&parmap->index, 1);
+
+ if (i < xbt_dynar_length(simix_global->process_to_run)) {
+ /* execute the next process */
+ XBT_DEBUG("Run next process");
+ next_context = xbt_dynar_get_as(simix_global->process_to_run, i, smx_process_t)->context;
+ }
+ else {
+ /* all processes were run, go to the barrier */
+ XBT_DEBUG("No more processes to run");
+ next_context = (smx_context_t) maestro_context;
+ }