]> AND Public Git Repository - simgrid.git/blobdiff - src/kernel/resource/CpuImpl.cpp
Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Strengthen debug messages on channel send/recv.
[simgrid.git] / src / kernel / resource / CpuImpl.cpp
index 9ff76514ae7ad30b68b11ad7e356fc8f86e6a322..c69d23ad5b100d443b72f7fd37f82784c30127e9 100644 (file)
@@ -4,9 +4,10 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "src/kernel/resource/CpuImpl.hpp"
+#include "src/kernel/EngineImpl.hpp"
+#include "src/kernel/resource/models/cpu_ti.hpp"
 #include "src/kernel/resource/profile/Profile.hpp"
-#include "src/surf/cpu_ti.hpp"
-#include "src/surf/surf_interface.hpp"
+#include "src/simgrid/math_utils.h"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(res_cpu, ker_resource, "CPU resource, fueling execution activites");
 
@@ -151,6 +152,23 @@ void CpuImpl::seal()
   Resource::seal();
 }
 
+void CpuImpl::turn_off()
+{
+  if (is_on()) {
+    Resource::turn_off();
+
+    const kernel::lmm::Element* elem = nullptr;
+    double now                       = EngineImpl::get_clock();
+    while (const auto* var = get_constraint()->get_variable(&elem)) {
+      Action* action = var->get_id();
+      if (action->get_state() == Action::State::INITED || action->get_state() == Action::State::STARTED) {
+        action->set_finish_time(now);
+        action->set_state(Action::State::FAILED);
+      }
+    }
+  }
+}
+
 /**********
  * Action *
  **********/