+ ThreadContext* maestro = (ThreadContext*)simix_global->maestro_process->context_;
+ maestro->end_.acquire();
+
+ Context::set_current(nullptr);
+}
+
+// SerialThreadContext
+
+void SerialThreadContext::run_all()
+{
+ for (smx_actor_t const& actor : simix_global->process_to_run) {
+ XBT_DEBUG("Handling %p", actor);
+ ThreadContext* context = static_cast<ThreadContext*>(actor->context_);
+ context->release();
+ context->wait();
+ }
+}
+
+// ParallelThreadContext
+
+xbt::OsSemaphore* ParallelThreadContext::thread_sem_ = nullptr;
+
+void ParallelThreadContext::initialize()
+{
+ thread_sem_ = new xbt::OsSemaphore(SIMIX_context_get_nthreads());
+}
+
+void ParallelThreadContext::finalize()
+{
+ delete thread_sem_;
+ thread_sem_ = nullptr;
+}
+
+void ParallelThreadContext::run_all()
+{
+ for (smx_actor_t const& actor : simix_global->process_to_run)
+ static_cast<ThreadContext*>(actor->context_)->release();
+ for (smx_actor_t const& actor : simix_global->process_to_run)
+ static_cast<ThreadContext*>(actor->context_)->wait();
+}
+
+void ParallelThreadContext::start_hook()
+{
+ if (not is_maestro()) /* parallel run */
+ thread_sem_->acquire();
+}