X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/1b0c79654be70819eb6fb89c05d03cf93d644376..28e6a5182f40acf3ea901f1c092ea680c33141d7:/src/kernel/context/ContextSwapped.cpp diff --git a/src/kernel/context/ContextSwapped.cpp b/src/kernel/context/ContextSwapped.cpp index aff10af720..89f1b49d34 100644 --- a/src/kernel/context/ContextSwapped.cpp +++ b/src/kernel/context/ContextSwapped.cpp @@ -38,15 +38,12 @@ void smx_ctx_wrapper(simgrid::kernel::context::SwappedContext* context) __sanitizer_finish_switch_fiber(nullptr, &context->asan_ctx_->asan_stack_, &context->asan_ctx_->asan_stack_size_); #endif try { - sthread_enable(); + const SThreadGuard sthread_guard; (*context)(); - sthread_disable(); context->stop(); } catch (simgrid::ForcefulKillException const&) { - sthread_disable(); XBT_DEBUG("Caught a ForcefulKillException"); } catch (simgrid::Exception const& e) { - sthread_disable(); XBT_INFO("Actor killed by an uncaught exception %s", boost::core::demangle(typeid(e).name()).c_str()); throw; } @@ -174,6 +171,7 @@ void SwappedContext::swap_into(SwappedContext* to) /** Maestro wants to run all ready actors */ void SwappedContextFactory::run_all(std::vector const& actors_list) { + const SThreadGuard sthread_guard; const auto* engine = EngineImpl::get_instance(); /* This function is called by maestro at the beginning of a scheduling round to get all working threads executing some * stuff It is much easier to understand what happens if you see the working threads as bodies that swap their soul @@ -222,7 +220,6 @@ void SwappedContext::resume() // Save my current soul (either maestro, or one of the minions) in a thread-specific area worker_context_ = old; } - sthread_enable(); // Switch my soul and the actor's one Context::set_current(this); old->swap_into(this); @@ -264,12 +261,10 @@ void SwappedContext::suspend() if (i < engine->get_actor_to_run_count()) { /* Actually swap into the next actor directly without transiting to maestro */ XBT_DEBUG("Run next actor"); - sthread_enable(); next_context = static_cast(engine->get_actor_to_run_at(i)->context_.get()); } else { /* all processes were run, actually return to maestro */ XBT_DEBUG("No more actors to run"); - sthread_disable(); next_context = factory_.maestro_context_; } }