+ /* 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
+}
+
+/**
+ * \brief Resumes sequentially in the current worker thread the processes ready
+ * to run.
+ * \param first_process the first process to resume
+ */
+static void smx_ctx_raw_resume_parallel(smx_process_t first_process)
+{
+#ifdef CONTEXT_THREADS
+ unsigned long worker_id = __sync_fetch_and_add(&raw_threads_working, 1);
+ xbt_os_thread_set_specific(raw_worker_id_key, (void*) worker_id);
+ XBT_DEBUG("Saving worker stack %lu", worker_id);
+ raw_stack_t* worker_stack = &raw_workers_stacks[worker_id];
+
+ smx_context_t context = first_process->context;
+ SIMIX_context_set_current(context);
+ raw_swapcontext(worker_stack, ((smx_ctx_raw_t) context)->stack_top);
+#endif
+}
+
+/**
+ * \brief Resumes in parallel all processes ready to run.
+ */
+static void smx_ctx_raw_runall_parallel(void)
+{
+#ifdef CONTEXT_THREADS
+ raw_threads_working = 0;
+ xbt_parmap_apply(raw_parmap, (void_f_pvoid_t) smx_ctx_raw_resume_parallel,