X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/955310e4fe48139407cabfd6cae815a287932291..7dd253f0ff4dda733dd0f7c924a25df4b777f0d0:/src/kernel/context/ContextSwapped.cpp diff --git a/src/kernel/context/ContextSwapped.cpp b/src/kernel/context/ContextSwapped.cpp index fbecf2b664..e2ca4165ff 100644 --- a/src/kernel/context/ContextSwapped.cpp +++ b/src/kernel/context/ContextSwapped.cpp @@ -38,22 +38,16 @@ namespace context { /* thread-specific storage for the worker's context */ thread_local SwappedContext* SwappedContext::worker_context_ = nullptr; -SwappedContextFactory::SwappedContextFactory() : ContextFactory(), parallel_(SIMIX_context_is_parallel()) -{ - parmap_ = nullptr; // will be created lazily with the right parameters if needed (ie, in parallel) -} - SwappedContext::SwappedContext(std::function&& code, smx_actor_t actor, SwappedContextFactory* factory) : Context(std::move(code), actor), factory_(factory) { // Save maestro (=context created first) in preparation for run_all - if (not factory->parallel_ && factory->maestro_context_ == nullptr) + if (not SIMIX_context_is_parallel() && factory->maestro_context_ == nullptr) factory->maestro_context_ = this; if (has_code()) { xbt_assert((smx_context_stack_size & 0xf) == 0, "smx_context_stack_size should be multiple of 16"); if (smx_context_guard_size > 0 && not MC_is_active()) { - #if !defined(PTH_STACKGROWTH) || (PTH_STACKGROWTH != -1) xbt_die( "Stack overflow protection is known to be broken on your system: you stacks grow upwards (or detection is " @@ -155,7 +149,7 @@ void SwappedContextFactory::run_all() * stuff It is much easier to understand what happens if you see the working threads as bodies that swap their soul * for the ones of the simulated processes that must run. */ - if (parallel_) { + if (SIMIX_context_is_parallel()) { // We lazily create the parmap so that all options are actually processed when doing so. if (parmap_ == nullptr) parmap_.reset( @@ -178,7 +172,7 @@ void SwappedContextFactory::run_all() return; /* maestro is already saved in the first slot of workers_context_ */ - smx_actor_t first_actor = simix_global->actors_to_run.front(); + const actor::ActorImpl* first_actor = simix_global->actors_to_run.front(); process_index_ = 1; /* execute the first actor; it will chain to the others when using suspend() */ static_cast(first_actor->context_.get())->resume(); @@ -193,7 +187,7 @@ void SwappedContextFactory::run_all() */ void SwappedContext::resume() { - if (factory_->parallel_) { + if (SIMIX_context_is_parallel()) { // Save my current soul (either maestro, or one of the minions) in a thread-specific area worker_context_ = static_cast(self()); // Switch my soul and the actor's one @@ -218,7 +212,7 @@ void SwappedContext::resume() */ void SwappedContext::suspend() { - if (factory_->parallel_) { + if (SIMIX_context_is_parallel()) { // Get some more work to directly swap into the next executable actor instead of yielding back to the parmap boost::optional next_work = factory_->parmap_->next(); SwappedContext* next_context;