+// 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& process : simix_global->process_to_run)
+ static_cast<ThreadContext*>(process->context_)->release();
+ for (smx_actor_t const& process : simix_global->process_to_run)
+ static_cast<ThreadContext*>(process->context_)->wait();
+}
+
+void ParallelThreadContext::start_hook()
+{
+ if (not is_maestro()) /* parallel run */
+ thread_sem_->acquire();
+}
+
+void ParallelThreadContext::yield_hook()
+{
+ if (not is_maestro()) /* parallel run */
+ thread_sem_->release();
+}
+
+XBT_PRIVATE ContextFactory* thread_factory()
+{
+ XBT_VERB("Activating thread context factory");
+ return new ThreadContextFactory();
+}