+// 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->actors_to_run)
+ static_cast<ThreadContext*>(actor->context_.get())->release();
+ for (smx_actor_t const& actor : simix_global->actors_to_run)
+ static_cast<ThreadContext*>(actor->context_.get())->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();
+}
+} // namespace context
+} // namespace kernel
+} // namespace simgrid