- xbt_parmap_apply(parmap, (void_f_pvoid_t)smx_ctx_sysv_resume_parallel, processes);
- xbt_dynar_reset(processes);
+#ifdef CONTEXT_THREADS
+ /* determine the next context */
+ smx_process_t next_work = xbt_parmap_next(sysv_parmap);
+ smx_context_t next_context;
+ ucontext_t* next_stack;
+
+ if (next_work != NULL) {
+ /* there is a next process to resume */
+ XBT_DEBUG("Run next process");
+ next_context = next_work->context;
+ next_stack = &((smx_ctx_sysv_t) next_context)->uc;
+ }
+ else {
+ /* all processes were run, go to the barrier */
+ XBT_DEBUG("No more processes to run");
+ unsigned long worker_id =
+ (unsigned long) xbt_os_thread_get_specific(sysv_worker_id_key);
+ next_context = (smx_context_t)sysv_workers_context[worker_id];
+ next_stack = &((smx_ctx_sysv_t)next_context)->uc;
+ }
+
+ SIMIX_context_set_current(next_context);
+ swapcontext(&((smx_ctx_sysv_t) context)->uc, next_stack);
+#endif