Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[SURF] Move Action::suspended_ to new enum class SuspendedStates
authorChristian Heinrich <franz-christian.heinrich@inria.fr>
Tue, 13 Feb 2018 16:41:52 +0000 (17:41 +0100)
committerChristian Heinrich <franz-christian.heinrich@inria.fr>
Tue, 13 Feb 2018 17:03:51 +0000 (18:03 +0100)
src/surf/cpu_cas01.cpp
src/surf/cpu_ti.cpp
src/surf/network_cm02.cpp
src/surf/ptask_L07.cpp
src/surf/storage_n11.cpp
src/surf/surf_interface.cpp
src/surf/surf_interface.hpp

index 1b9f80d..369d1f7 100644 (file)
@@ -175,7 +175,7 @@ CpuAction *CpuCas01::sleep(double duration)
 
   // FIXME: sleep variables should not consume 1.0 in System::expand()
   action->setMaxDuration(duration);
 
   // FIXME: sleep variables should not consume 1.0 in System::expand()
   action->setMaxDuration(duration);
-  action->suspended_ = 2;
+  action->suspended_ = Action::SuspendStates::sleeping;
   if (duration < 0) { // NO_MAX_DURATION
     /* Move to the *end* of the corresponding action set. This convention is used to speed up update_resource_state */
     simgrid::xbt::intrusive_erase(*action->getStateSet(), *action);
   if (duration < 0) { // NO_MAX_DURATION
     /* Move to the *end* of the corresponding action set. This convention is used to speed up update_resource_state */
     simgrid::xbt::intrusive_erase(*action->getStateSet(), *action);
index 3fc88fe..462b806 100644 (file)
@@ -473,7 +473,7 @@ void CpuTi::updateActionsFinishTime(double now)
       continue;
 
     /* action suspended, skip it */
       continue;
 
     /* action suspended, skip it */
-    if (action.suspended_ != 0)
+    if (action.suspended_ != Action::SuspendStates::not_suspended)
       continue;
 
     sum_priority += 1.0 / action.getPriority();
       continue;
 
     sum_priority += 1.0 / action.getPriority();
@@ -487,7 +487,7 @@ void CpuTi::updateActionsFinishTime(double now)
       continue;
 
     /* verify if the action is really running on cpu */
       continue;
 
     /* verify if the action is really running on cpu */
-    if (action.suspended_ == 0 && action.getPriority() > 0) {
+    if (action.suspended_ == Action::SuspendStates::not_suspended && action.getPriority() > 0) {
       /* total area needed to finish the action. Used in trace integration */
       total_area = (action.getRemains()) * sum_priority * action.getPriority();
 
       /* total area needed to finish the action. Used in trace integration */
       total_area = (action.getRemains()) * sum_priority * action.getPriority();
 
@@ -550,7 +550,7 @@ void CpuTi::updateRemainingAmount(double now)
       continue;
 
     /* action suspended, skip it */
       continue;
 
     /* action suspended, skip it */
-    if (action.suspended_ != 0)
+    if (action.suspended_ != Action::SuspendStates::not_suspended)
       continue;
 
     /* action don't need update */
       continue;
 
     /* action don't need update */
@@ -589,7 +589,7 @@ CpuAction *CpuTi::sleep(double duration)
   CpuTiAction* action = new CpuTiAction(static_cast<CpuTiModel*>(model()), 1.0, isOff(), this);
 
   action->setMaxDuration(duration);
   CpuTiAction* action = new CpuTiAction(static_cast<CpuTiModel*>(model()), 1.0, isOff(), this);
 
   action->setMaxDuration(duration);
-  action->suspended_ = 2;
+  action->suspended_ = Action::SuspendStates::sleeping;
   if (duration == NO_MAX_DURATION) {
     /* Move to the *end* of the corresponding action set. This convention is used to speed up update_resource_state */
     simgrid::xbt::intrusive_erase(*action->getStateSet(), *action);
   if (duration == NO_MAX_DURATION) {
     /* Move to the *end* of the corresponding action set. This convention is used to speed up update_resource_state */
     simgrid::xbt::intrusive_erase(*action->getStateSet(), *action);
@@ -660,8 +660,8 @@ void CpuTiAction::cancel()
 void CpuTiAction::suspend()
 {
   XBT_IN("(%p)", this);
 void CpuTiAction::suspend()
 {
   XBT_IN("(%p)", this);
-  if (suspended_ != 2) {
-    suspended_ = 1;
+  if (suspended_ != Action::SuspendStates::sleeping) {
+    suspended_ = Action::SuspendStates::suspended;
     heapRemove(getModel()->getActionHeap());
     cpu_->modified(true);
   }
     heapRemove(getModel()->getActionHeap());
     cpu_->modified(true);
   }
@@ -671,8 +671,8 @@ void CpuTiAction::suspend()
 void CpuTiAction::resume()
 {
   XBT_IN("(%p)", this);
 void CpuTiAction::resume()
 {
   XBT_IN("(%p)", this);
-  if (suspended_ != 2) {
-    suspended_ = 0;
+  if (suspended_ != Action::SuspendStates::sleeping) {
+    suspended_ = Action::SuspendStates::not_suspended;
     cpu_->modified(true);
   }
   XBT_OUT();
     cpu_->modified(true);
   }
   XBT_OUT();
index e199003..e13ab8f 100644 (file)
@@ -464,7 +464,7 @@ void NetworkCm02Link::setLatency(double value)
 
 void NetworkCm02Action::updateRemainingLazy(double now)
 {
 
 void NetworkCm02Action::updateRemainingLazy(double now)
 {
-  if (suspended_ != 0)
+  if (suspended_ != Action::SuspendStates::not_suspended)
     return;
 
   double delta        = now - getLastUpdate();
     return;
 
   double delta        = now - getLastUpdate();
index 33644e2..8dcaf9b 100644 (file)
@@ -277,7 +277,7 @@ Action *CpuL07::sleep(double duration)
 {
   L07Action *action = static_cast<L07Action*>(execution_start(1.0));
   action->setMaxDuration(duration);
 {
   L07Action *action = static_cast<L07Action*>(execution_start(1.0));
   action->setMaxDuration(duration);
-  action->suspended_ = 2;
+  action->suspended_ = Action::SuspendStates::sleeping;
   model()->getMaxminSystem()->update_variable_weight(action->getVariable(), 0.0);
 
   return action;
   model()->getMaxminSystem()->update_variable_weight(action->getVariable(), 0.0);
 
   return action;
@@ -402,7 +402,7 @@ void L07Action::updateBound()
   }
   double lat_bound = sg_tcp_gamma / (2.0 * lat_current);
   XBT_DEBUG("action (%p) : lat_bound = %g", this, lat_bound);
   }
   double lat_bound = sg_tcp_gamma / (2.0 * lat_current);
   XBT_DEBUG("action (%p) : lat_bound = %g", this, lat_bound);
-  if ((latency_ <= 0.0) && (suspended_ == 0)) {
+  if ((latency_ <= 0.0) && (suspended_ == Action::SuspendStates::not_suspended)) {
     if (rate_ < 0)
       getModel()->getMaxminSystem()->update_variable_bound(getVariable(), lat_bound);
     else
     if (rate_ < 0)
       getModel()->getMaxminSystem()->update_variable_bound(getVariable(), lat_bound);
     else
index 130879d..d7c60e3 100644 (file)
@@ -162,9 +162,9 @@ void StorageN11Action::cancel()
 void StorageN11Action::suspend()
 {
   XBT_IN("(%p)", this);
 void StorageN11Action::suspend()
 {
   XBT_IN("(%p)", this);
-  if (suspended_ != 2) {
+  if (suspended_ != Action::SuspendStates::sleeping) {
     getModel()->getMaxminSystem()->update_variable_weight(getVariable(), 0.0);
     getModel()->getMaxminSystem()->update_variable_weight(getVariable(), 0.0);
-    suspended_ = 1;
+    suspended_ = Action::SuspendStates::suspended;
   }
   XBT_OUT();
 }
   }
   XBT_OUT();
 }
@@ -176,7 +176,7 @@ void StorageN11Action::resume()
 
 bool StorageN11Action::isSuspended()
 {
 
 bool StorageN11Action::isSuspended()
 {
-  return suspended_ == 1;
+  return suspended_ == Action::SuspendStates::suspended;
 }
 
 void StorageN11Action::setMaxDuration(double /*duration*/)
 }
 
 void StorageN11Action::setMaxDuration(double /*duration*/)
index 7a5a55c..b69e677 100644 (file)
@@ -717,7 +717,7 @@ int Action::unref(){
 void Action::suspend()
 {
   XBT_IN("(%p)", this);
 void Action::suspend()
 {
   XBT_IN("(%p)", this);
-  if (suspended_ != 2) {
+  if (suspended_ != SuspendStates::sleeping) {
     getModel()->getMaxminSystem()->update_variable_weight(getVariable(), 0.0);
     if (getModel()->getUpdateMechanism() == UM_LAZY){
       heapRemove(getModel()->getActionHeap());
     getModel()->getMaxminSystem()->update_variable_weight(getVariable(), 0.0);
     if (getModel()->getUpdateMechanism() == UM_LAZY){
       heapRemove(getModel()->getActionHeap());
@@ -727,7 +727,7 @@ void Action::suspend()
         updateRemainingLazy(surf_get_clock());
       }
     }
         updateRemainingLazy(surf_get_clock());
       }
     }
-    suspended_ = 1;
+    suspended_ = SuspendStates::suspended;
   }
   XBT_OUT();
 }
   }
   XBT_OUT();
 }
@@ -735,9 +735,9 @@ void Action::suspend()
 void Action::resume()
 {
   XBT_IN("(%p)", this);
 void Action::resume()
 {
   XBT_IN("(%p)", this);
-  if (suspended_ != 2) {
+  if (suspended_ != SuspendStates::sleeping) {
     getModel()->getMaxminSystem()->update_variable_weight(getVariable(), getPriority());
     getModel()->getMaxminSystem()->update_variable_weight(getVariable(), getPriority());
-    suspended_ = 0;
+    suspended_ = SuspendStates::not_suspended;
     if (getModel()->getUpdateMechanism() == UM_LAZY)
       heapRemove(getModel()->getActionHeap());
   }
     if (getModel()->getUpdateMechanism() == UM_LAZY)
       heapRemove(getModel()->getActionHeap());
   }
@@ -746,7 +746,7 @@ void Action::resume()
 
 bool Action::isSuspended()
 {
 
 bool Action::isSuspended()
 {
-  return suspended_ == 1;
+  return suspended_ == SuspendStates::suspended;
 }
 /* insert action on heap using a given key and a hat (heap_action_type)
  * a hat can be of three types for communications:
 }
 /* insert action on heap using a given key and a hat (heap_action_type)
  * a hat can be of three types for communications:
index 507c7ce..8b16ee0 100644 (file)
@@ -129,6 +129,12 @@ public:
     not_in_the_system /**< Not in the system anymore. Why did you ask ? */
   };
 
     not_in_the_system /**< Not in the system anymore. Why did you ask ? */
   };
 
+  enum class SuspendStates {
+    not_suspended = 0, /**< Action currently not suspended **/
+    suspended,
+    sleeping
+  };
+
   /**
    * @brief Action constructor
    *
   /**
    * @brief Action constructor
    *
@@ -280,7 +286,7 @@ public:
   enum heap_action_type getHat() const { return hat_; }
   bool is_linked() const { return action_lmm_hook.is_linked(); }
 protected:
   enum heap_action_type getHat() const { return hat_; }
   bool is_linked() const { return action_lmm_hook.is_linked(); }
 protected:
-  int suspended_ = 0;
+  Action::SuspendStates suspended_ = Action::SuspendStates::not_suspended;
 };
 
 typedef Action::ActionList ActionList;
 };
 
 typedef Action::ActionList ActionList;