X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/b8df87e176f27b25534f27d7e240defa32ca35bc..3baaf982217fbc818965e8ed71c3ec91e96844d5:/src/kernel/context/ContextSwapped.cpp diff --git a/src/kernel/context/ContextSwapped.cpp b/src/kernel/context/ContextSwapped.cpp index a270f90fc0..7775167df7 100644 --- a/src/kernel/context/ContextSwapped.cpp +++ b/src/kernel/context/ContextSwapped.cpp @@ -37,8 +37,7 @@ namespace context { /* rank of the execution thread */ thread_local uintptr_t SwappedContext::worker_id_; /* thread-specific storage for the thread id */ -SwappedContextFactory::SwappedContextFactory(std::string name) - : ContextFactory(name), parallel_(SIMIX_context_is_parallel()) +SwappedContextFactory::SwappedContextFactory() : ContextFactory(), parallel_(SIMIX_context_is_parallel()) { parmap_ = nullptr; // will be created lazily with the right parameters if needed (ie, in parallel) workers_context_.clear(); @@ -55,6 +54,10 @@ SwappedContext::SwappedContext(std::function code, void_pfn_smxprocess_t SwappedContextFactory* factory) : Context(std::move(code), cleanup_func, process), factory_(factory) { + // Save maestro (=context created first) in preparation for run_all + if (factory_->workers_context_[0] == nullptr) + factory_->workers_context_[0] = this; + if (has_code()) { if (smx_context_guard_size > 0 && not MC_is_active()) { @@ -134,10 +137,9 @@ SwappedContext::~SwappedContext() xbt_free(stack_); } -void SwappedContext::set_maestro(SwappedContext* ctx) +void* SwappedContext::get_stack() { - if (factory_->threads_working_ == 0) // Don't save the soul of minions, only the one of maestro - factory_->workers_context_[0] = ctx; + return stack_; } void SwappedContext::stop()