- smx_context_t context = process->context;
- xbt_os_thread_set_extra_data(context);
- int rv = swapcontext(&((smx_ctx_sysv_t)context)->old_uc, &((smx_ctx_sysv_t) context)->uc);
- xbt_os_thread_set_extra_data(NULL);
+ smx_ctx_base_stop(context);
+ smx_ctx_sysv_suspend_parallel(context);
+}
+
+static void smx_ctx_sysv_suspend_parallel(smx_context_t context)
+{
+#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");
+ next_context = (smx_context_t) sysv_maestro_context;
+ unsigned long worker_id =
+ (unsigned long) xbt_os_thread_get_specific(sysv_worker_id_key);
+ next_stack = &sysv_workers_stacks[worker_id];
+ }