Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
play with (parallel) execs. still not satisfying
[simgrid.git] / src / kernel / activity / ExecImpl.cpp
index 0969448..a55c1f3 100644 (file)
@@ -15,9 +15,9 @@
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_process);
 
-void simcall_HANDLER_execution_wait(smx_simcall_t simcall, smx_activity_t synchro)
+void simcall_HANDLER_execution_wait(smx_simcall_t simcall, simgrid::kernel::activity::ExecImpl* synchro)
 {
-  XBT_DEBUG("Wait for execution of synchro %p, state %d", synchro.get(), (int)synchro->state_);
+  XBT_DEBUG("Wait for execution of synchro %p, state %d", synchro, (int)synchro->state_);
 
   /* Associate this simcall to the synchro */
   synchro->simcalls_.push_back(simcall);
@@ -26,21 +26,21 @@ void simcall_HANDLER_execution_wait(smx_simcall_t simcall, smx_activity_t synchr
   /* set surf's synchro */
   if (MC_is_active() || MC_record_replay_is_active()) {
     synchro->state_ = SIMIX_DONE;
-    boost::static_pointer_cast<simgrid::kernel::activity::ExecImpl>(synchro)->finish();
+    synchro->finish();
     return;
   }
 
   /* If the synchro is already finished then perform the error handling */
   if (synchro->state_ != SIMIX_RUNNING)
-    boost::static_pointer_cast<simgrid::kernel::activity::ExecImpl>(synchro)->finish();
+    synchro->finish();
 }
 
-void simcall_HANDLER_execution_test(smx_simcall_t simcall, smx_activity_t synchro)
+void simcall_HANDLER_execution_test(smx_simcall_t simcall, simgrid::kernel::activity::ExecImpl* synchro)
 {
   int res = (synchro->state_ != SIMIX_WAITING && synchro->state_ != SIMIX_RUNNING);
   if (res) {
     synchro->simcalls_.push_back(simcall);
-    boost::static_pointer_cast<simgrid::kernel::activity::ExecImpl>(synchro)->finish();
+    synchro->finish();
   } else {
     SIMIX_simcall_answer(simcall);
   }
@@ -51,15 +51,22 @@ namespace simgrid {
 namespace kernel {
 namespace activity {
 
-ExecImpl::ExecImpl(std::string name, std::string tracing_category, resource::Action* timeout_detector, s4u::Host* host)
-    : ActivityImpl(std::move(name)), host_(host), timeout_detector_(timeout_detector)
+ExecImpl::ExecImpl(std::string name, std::string tracing_category, s4u::Host* host)
+    : ActivityImpl(std::move(name)), host_(host)
 {
   this->state_ = SIMIX_RUNNING;
   this->set_category(std::move(tracing_category));
 
-  if (timeout_detector != nullptr)
-    timeout_detector_->set_data(this);
+  XBT_DEBUG("Create exec %p", this);
+}
 
+ExecImpl::ExecImpl(std::string name, std::string tracing_category, s4u::Host* host, double timeout)
+    : ExecImpl(std::move(name), std::move(tracing_category), nullptr)
+{
+  if (timeout > 0 && not MC_is_active() && not MC_record_replay_is_active()) {
+    timeout_detector_ = host->pimpl_cpu->sleep(timeout);
+    timeout_detector_->set_data(this);
+  }
   XBT_DEBUG("Create exec %p", this);
 }