From: Martin Quinson Date: Sun, 6 Jan 2019 11:06:03 +0000 (+0100) Subject: move a static field of SwappedContext into SwappedContextFactory X-Git-Tag: v3_22~671 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/ef124af903bef166526a5e5a34e035db21876103?ds=inline move a static field of SwappedContext into SwappedContextFactory --- diff --git a/src/kernel/context/ContextSwapped.cpp b/src/kernel/context/ContextSwapped.cpp index 19f874d5ae..4d277b7ed7 100644 --- a/src/kernel/context/ContextSwapped.cpp +++ b/src/kernel/context/ContextSwapped.cpp @@ -35,9 +35,6 @@ namespace simgrid { namespace kernel { namespace context { -/* Sequential execution */ -unsigned long SwappedContext::process_index_; - /* Parallel execution */ simgrid::xbt::Parmap* SwappedContext::parmap_; std::atomic SwappedContext::threads_working_; /* number of threads that have started their work */ @@ -84,10 +81,10 @@ void SwappedContextFactory::run_all() } else { // sequential execution if (simix_global->process_to_run.empty()) return; - smx_actor_t first_process = simix_global->process_to_run.front(); - SwappedContext::process_index_ = 1; - /* execute the first process */ - static_cast(first_process->context_)->resume(); + smx_actor_t first_actor = simix_global->process_to_run.front(); + process_index_ = 1; + /* execute the first actor; it will chain to the others when using suspend() */ + static_cast(first_actor->context_)->resume(); } } @@ -213,8 +210,8 @@ void SwappedContext::suspend() } else { // sequential execution /* determine the next context */ SwappedContext* next_context; - unsigned long int i = process_index_; - process_index_++; + unsigned long int i = factory_->process_index_; + factory_->process_index_++; if (i < simix_global->process_to_run.size()) { /* Actually swap into the next actor directly without transiting to maestro */ diff --git a/src/kernel/context/ContextSwapped.hpp b/src/kernel/context/ContextSwapped.hpp index 46c0b0946d..cfb9361f57 100644 --- a/src/kernel/context/ContextSwapped.hpp +++ b/src/kernel/context/ContextSwapped.hpp @@ -22,8 +22,11 @@ public: ~SwappedContextFactory() override; void run_all() override; -protected: // FIXME temporary internal exposure +protected: bool parallel_; + +private: + unsigned long process_index_ = 0; // Next actor to execute during sequential run_all() }; class SwappedContext : public Context { @@ -43,9 +46,7 @@ public: static SwappedContext* get_maestro() { return maestro_context_; } static void set_maestro(SwappedContext* maestro) { maestro_context_ = maestro; } - static unsigned long process_index_; // FIXME killme - - /* For the parallel execution */ + /* For the parallel execution */ // FIXME killme static simgrid::xbt::Parmap* parmap_; static std::vector workers_context_; static std::atomic threads_working_;