-
-#if HAVE_THREAD_CONTEXTS
-static simgrid::xbt::Parmap<smx_actor_t>* sysv_parmap;
-static simgrid::kernel::context::UContext** sysv_workers_context; /* space to save the worker's context
- * in each thread */
-static uintptr_t sysv_threads_working; /* number of threads that have started their work */
-static xbt_os_thread_key_t sysv_worker_id_key; /* thread-specific storage for the thread id */
-#endif
-static unsigned long sysv_process_index = 0; /* index of the next process to run in the
- * list of runnable processes */
-static simgrid::kernel::context::UContext* sysv_maestro_context;
-static bool sysv_parallel;
-
-// The name of this function is currently hardcoded in the code (as string).
-// Do not change it without fixing those references as well.
-static void smx_ctx_sysv_wrapper(int, int);
-
-namespace simgrid {
-namespace kernel {
-namespace context {
-
-class UContext : public Context {
-private:
- ucontext_t uc_; /* the ucontext that executes the code */
- char *stack_ = nullptr; /* the thread stack */
-public:
- friend UContextFactory;
- UContext(std::function<void()> code,
- void_pfn_smxprocess_t cleanup_func, smx_actor_t process);
- ~UContext() override;
- void stop() override;
- static void swap(UContext* from, UContext* to) { swapcontext(&from->uc_, &to->uc_); }
-};
-
-class SerialUContext : public UContext {
-public:
- SerialUContext(std::function<void()> code,
- void_pfn_smxprocess_t cleanup_func, smx_actor_t process)
- : UContext(std::move(code), cleanup_func, process)
- {}
- void suspend() override;
- void resume();
-};
-
-class ParallelUContext : public UContext {
-public:
- ParallelUContext(std::function<void()> code,
- void_pfn_smxprocess_t cleanup_func, smx_actor_t process)
- : UContext(std::move(code), cleanup_func, process)
- {}
- void suspend() override;
- void resume();
-};
-
-class UContextFactory : public ContextFactory {
-public:
- friend UContext;
- friend SerialUContext;
- friend ParallelUContext;
-
- UContextFactory();
- ~UContextFactory() override;
- Context* create_context(std::function<void()> code,
- void_pfn_smxprocess_t cleanup, smx_actor_t process) override;
- void run_all() override;
-};
-
-XBT_PRIVATE ContextFactory* sysv_factory()
-{
- XBT_VERB("Activating SYSV context factory");
- return new UContextFactory();