Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cleanups in Action::State
authorMartin Quinson <martin.quinson@loria.fr>
Thu, 17 May 2018 19:30:15 +0000 (21:30 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Thu, 17 May 2018 19:45:55 +0000 (21:45 +0200)
- Rename "ready" to "inited", for symmetry to s4u::Activity
- Remove the unused state "to_free"
- Rename the funky state "not_in_the_system" into "ignored", and
  improve its documentation.

Further cleanups could include not having any action set beyond the
ones existing in kernel::resource::Model, so that
kernel::resource::Action::get_state() see them all.

CpuCas01 is the one heavily using ignored actions, as failure detectors.

include/simgrid/kernel/resource/Action.hpp
include/simgrid/kernel/resource/Model.hpp
src/kernel/resource/Action.cpp
src/kernel/resource/Model.cpp
src/surf/cpu_cas01.cpp
src/surf/cpu_ti.cpp
src/surf/network_cm02.cpp
teshsuite/surf/surf_usage/surf_usage.cpp

index d482732..95a5947 100644 (file)
@@ -62,12 +62,11 @@ public:
       StateSet;
 
   enum class State {
       StateSet;
 
   enum class State {
-    ready = 0,        /**< Ready        */
-    running,          /**< Running      */
-    failed,           /**< Task Failure */
-    done,             /**< Completed    */
-    to_free,          /**< Action to free in next cleanup */
-    not_in_the_system /**< Not in the system anymore. Why did you ask ? */
+    inited,  /**< Created, but not started yet */
+    running, /**< Started, currently running */
+    failed,  /**< Completed (unsuccessfully: either the resource failed, or the action was canceled) */
+    done,    /**< Completed (successfully) */
+    ignored  /**< e.g. failure detectors, these infinite sleep actions that are put on resources which failure should be notified */
   };
 
   enum class SuspendStates {
   };
 
   enum class SuspendStates {
index 045d201..399a507 100644 (file)
@@ -31,8 +31,8 @@ public:
 
   virtual ~Model();
 
 
   virtual ~Model();
 
-  /** @brief Get the set of [actions](@ref Action) in *ready* state */
-  Action::StateSet* get_ready_action_set() const { return ready_action_set_; }
+  /** @brief Get the set of [actions](@ref Action) in *inited* state */
+  Action::StateSet* get_inited_action_set() const { return inited_action_set_; }
 
   /** @brief Get the set of [actions](@ref Action) in *running* state */
   Action::StateSet* get_running_action_set() const { return running_action_set_; }
 
   /** @brief Get the set of [actions](@ref Action) in *running* state */
   Action::StateSet* get_running_action_set() const { return running_action_set_; }
@@ -88,10 +88,10 @@ public:
 private:
   lmm::System* maxmin_system_           = nullptr;
   const UpdateAlgo update_algorithm_;
 private:
   lmm::System* maxmin_system_           = nullptr;
   const UpdateAlgo update_algorithm_;
-  Action::StateSet* ready_action_set_   = new Action::StateSet(); /**< Actions in state SURF_ACTION_READY */
-  Action::StateSet* running_action_set_ = new Action::StateSet(); /**< Actions in state SURF_ACTION_RUNNING */
-  Action::StateSet* failed_action_set_  = new Action::StateSet(); /**< Actions in state SURF_ACTION_FAILED */
-  Action::StateSet* done_action_set_    = new Action::StateSet(); /**< Actions in state SURF_ACTION_DONE */
+  Action::StateSet* inited_action_set_  = new Action::StateSet(); /**< Created not started */
+  Action::StateSet* running_action_set_ = new Action::StateSet(); /**< Started not done */
+  Action::StateSet* failed_action_set_  = new Action::StateSet(); /**< Done with failure */
+  Action::StateSet* done_action_set_    = new Action::StateSet(); /**< Done successful */
   ActionHeap action_heap_;
 };
 
   ActionHeap action_heap_;
 };
 
index 430c897..02505ea 100644 (file)
@@ -55,23 +55,23 @@ void Action::finish(Action::State state)
 
 Action::State Action::get_state() const
 {
 
 Action::State Action::get_state() const
 {
-  if (state_set_ == model_->get_ready_action_set())
-    return Action::State::ready;
+  if (state_set_ == model_->get_inited_action_set())
+    return Action::State::inited;
   if (state_set_ == model_->get_running_action_set())
     return Action::State::running;
   if (state_set_ == model_->get_failed_action_set())
     return Action::State::failed;
   if (state_set_ == model_->get_done_action_set())
     return Action::State::done;
   if (state_set_ == model_->get_running_action_set())
     return Action::State::running;
   if (state_set_ == model_->get_failed_action_set())
     return Action::State::failed;
   if (state_set_ == model_->get_done_action_set())
     return Action::State::done;
-  return Action::State::not_in_the_system;
+  return Action::State::ignored;
 }
 
 void Action::set_state(Action::State state)
 {
   simgrid::xbt::intrusive_erase(*state_set_, *this);
   switch (state) {
 }
 
 void Action::set_state(Action::State state)
 {
   simgrid::xbt::intrusive_erase(*state_set_, *this);
   switch (state) {
-    case Action::State::ready:
-      state_set_ = model_->get_ready_action_set();
+    case Action::State::inited:
+      state_set_ = model_->get_inited_action_set();
       break;
     case Action::State::running:
       state_set_ = model_->get_running_action_set();
       break;
     case Action::State::running:
       state_set_ = model_->get_running_action_set();
index 7f8fff9..f73ee98 100644 (file)
@@ -16,7 +16,7 @@ Model::Model(Model::UpdateAlgo algo) : update_algorithm_(algo) {}
 
 Model::~Model()
 {
 
 Model::~Model()
 {
-  delete ready_action_set_;
+  delete inited_action_set_;
   delete running_action_set_;
   delete failed_action_set_;
   delete done_action_set_;
   delete running_action_set_;
   delete failed_action_set_;
   delete done_action_set_;
index 57eb37e..e01b903 100644 (file)
@@ -151,9 +151,9 @@ void CpuCas01::apply_event(tmgr_trace_event_t event, double value)
       while ((var = cnst->get_variable(&elem))) {
         kernel::resource::Action* action = static_cast<kernel::resource::Action*>(var->get_id());
 
       while ((var = cnst->get_variable(&elem))) {
         kernel::resource::Action* action = static_cast<kernel::resource::Action*>(var->get_id());
 
-        if (action->get_state() == kernel::resource::Action::State::running ||
-            action->get_state() == kernel::resource::Action::State::ready ||
-            action->get_state() == kernel::resource::Action::State::not_in_the_system) {
+        if (action->get_state() == kernel::resource::Action::State::inited ||
+            action->get_state() == kernel::resource::Action::State::running ||
+            action->get_state() == kernel::resource::Action::State::ignored) {
           action->set_finish_time(date);
           action->set_state(kernel::resource::Action::State::failed);
         }
           action->set_finish_time(date);
           action->set_state(kernel::resource::Action::State::failed);
         }
index 53e49eb..b1928e4 100644 (file)
@@ -413,9 +413,9 @@ void CpuTi::apply_event(tmgr_trace_event_t event, double value)
 
       /* put all action running on cpu to failed */
       for (CpuTiAction& action : action_set_) {
 
       /* put all action running on cpu to failed */
       for (CpuTiAction& action : action_set_) {
-        if (action.get_state() == kernel::resource::Action::State::running ||
-            action.get_state() == kernel::resource::Action::State::ready ||
-            action.get_state() == kernel::resource::Action::State::not_in_the_system) {
+        if (action.get_state() == kernel::resource::Action::State::inited ||
+            action.get_state() == kernel::resource::Action::State::running ||
+            action.get_state() == kernel::resource::Action::State::ignored) {
           action.set_finish_time(date);
           action.set_state(kernel::resource::Action::State::failed);
           get_model()->get_action_heap().remove(&action);
           action.set_finish_time(date);
           action.set_state(kernel::resource::Action::State::failed);
           get_model()->get_action_heap().remove(&action);
index 4fde97a..761f90d 100644 (file)
@@ -349,7 +349,7 @@ void NetworkCm02Link::apply_event(tmgr_trace_event_t triggered, double value)
       while ((var = get_constraint()->get_variable(&elem))) {
         Action* action = static_cast<Action*>(var->get_id());
 
       while ((var = get_constraint()->get_variable(&elem))) {
         Action* action = static_cast<Action*>(var->get_id());
 
-        if (action->get_state() == Action::State::running || action->get_state() == Action::State::ready) {
+        if (action->get_state() == Action::State::inited || action->get_state() == Action::State::running) {
           action->set_finish_time(now);
           action->set_state(Action::State::failed);
         }
           action->set_finish_time(now);
           action->set_state(Action::State::failed);
         }
index 153da3f..6299c7c 100644 (file)
@@ -16,16 +16,16 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test, "Messages specific for surf example");
 static const char* string_action(simgrid::kernel::resource::Action::State state)
 {
   switch (state) {
 static const char* string_action(simgrid::kernel::resource::Action::State state)
 {
   switch (state) {
-    case simgrid::kernel::resource::Action::State::ready:
-      return "SURF_ACTION_READY";
+    case simgrid::kernel::resource::Action::State::inited:
+      return "SURF_ACTION_INITED";
     case simgrid::kernel::resource::Action::State::running:
       return "SURF_ACTION_RUNNING";
     case simgrid::kernel::resource::Action::State::failed:
       return "SURF_ACTION_FAILED";
     case simgrid::kernel::resource::Action::State::done:
       return "SURF_ACTION_DONE";
     case simgrid::kernel::resource::Action::State::running:
       return "SURF_ACTION_RUNNING";
     case simgrid::kernel::resource::Action::State::failed:
       return "SURF_ACTION_FAILED";
     case simgrid::kernel::resource::Action::State::done:
       return "SURF_ACTION_DONE";
-    case simgrid::kernel::resource::Action::State::not_in_the_system:
-      return "SURF_ACTION_NOT_IN_THE_SYSTEM";
+    case simgrid::kernel::resource::Action::State::ignored:
+      return "SURF_ACTION_IGNORED";
     default:
       return "INVALID STATE";
   }
     default:
       return "INVALID STATE";
   }