X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/8813202c9b93bd164e386568e895d715af0ac9ee..73a0ae62cf92da83e861cfaf9ba0313cacbc4825:/src/kernel/context/ContextSwapped.cpp diff --git a/src/kernel/context/ContextSwapped.cpp b/src/kernel/context/ContextSwapped.cpp index a4ab5b3558..599d52a6b3 100644 --- a/src/kernel/context/ContextSwapped.cpp +++ b/src/kernel/context/ContextSwapped.cpp @@ -8,6 +8,7 @@ #include "src/internal_config.h" #include "src/kernel/EngineImpl.hpp" #include "src/kernel/actor/ActorImpl.hpp" +#include "src/sthread/sthread.h" #include "xbt/parmap.hpp" #include "src/kernel/context/ContextSwapped.hpp" @@ -48,11 +49,15 @@ 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(); (*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; } @@ -63,9 +68,7 @@ void smx_ctx_wrapper(simgrid::kernel::context::SwappedContext* context) THROW_IMPOSSIBLE; } -namespace simgrid { -namespace kernel { -namespace context { +namespace simgrid::kernel::context { /* thread-specific storage for the worker's context */ thread_local SwappedContext* SwappedContext::worker_context_ = nullptr; @@ -246,6 +249,7 @@ 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); @@ -287,10 +291,12 @@ 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_; } } @@ -298,6 +304,4 @@ void SwappedContext::suspend() this->swap_into(next_context); } -} // namespace context -} // namespace kernel -} // namespace simgrid +} // namespace simgrid::kernel::context