+#ifdef CONTEXT_THREADS
+ /* determine the next context */
+ smx_process_t next_work = xbt_parmap_next(raw_parmap);
+ smx_context_t next_context;
+ raw_stack_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_raw_t) next_context)->stack_top;
+ }
+ else {
+ /* all processes were run, go to the barrier */
+ XBT_DEBUG("No more processes to run");
+ next_context = (smx_context_t) raw_maestro_context;
+ unsigned long worker_id =
+ (unsigned long) xbt_os_thread_get_specific(raw_worker_id_key);
+ XBT_DEBUG("Restoring worker stack %lu (working threads = %lu)",
+ worker_id, raw_threads_working);
+ next_stack = raw_workers_stacks[worker_id];
+ }
+
+ SIMIX_context_set_current(next_context);
+ raw_swapcontext(&((smx_ctx_raw_t) context)->stack_top, next_stack);
+#endif