Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
convert simcall_process_sleep to modernity
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Sat, 10 Aug 2019 13:41:08 +0000 (15:41 +0200)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Sat, 10 Aug 2019 13:41:08 +0000 (15:41 +0200)
src/kernel/activity/SleepImpl.cpp
src/kernel/actor/ActorImpl.cpp
src/s4u/s4u_Actor.cpp
src/simix/libsmx.cpp
src/simix/popping_accessors.hpp
src/simix/popping_bodies.cpp
src/simix/popping_enum.h
src/simix/popping_generated.cpp
src/simix/simcalls.in

index 90d88e9..4cf4808 100644 (file)
@@ -57,7 +57,6 @@ void SleepImpl::finish()
     smx_simcall_t simcall = simcalls_.front();
     simcalls_.pop_front();
 
-    simcall_process_sleep__set__result(simcall, state_);
     simcall->issuer->waiting_synchro = nullptr;
     if (simcall->issuer->is_suspended()) {
       XBT_DEBUG("Wait! This process is suspended and can't wake up now.");
index 08199ba..d8214a7 100644 (file)
@@ -600,19 +600,6 @@ const char* SIMIX_process_self_get_name()
   return process->get_cname();
 }
 
-void simcall_HANDLER_process_sleep(smx_simcall_t simcall, double duration)
-{
-  if (MC_is_active() || MC_record_replay_is_active()) {
-    MC_process_clock_add(simcall->issuer, duration);
-    simcall_process_sleep__set__result(simcall, SIMIX_DONE);
-    simcall->issuer->simcall_answer();
-    return;
-  }
-  smx_activity_t sync = simcall->issuer->sleep(duration);
-  sync->simcalls_.push_back(simcall);
-  simcall->issuer->waiting_synchro = sync;
-}
-
 /**
  * @brief Calling this function makes the process to yield.
  *
index 5732d13..e351ed7 100644 (file)
@@ -5,11 +5,14 @@
 
 #include "simgrid/Exception.hpp"
 #include "simgrid/actor.h"
+#include "simgrid/modelchecker.h"
 #include "simgrid/s4u/Actor.hpp"
 #include "simgrid/s4u/Exec.hpp"
 #include "simgrid/s4u/Host.hpp"
 #include "simgrid/s4u/VirtualMachine.hpp"
+#include "src/include/mc/mc.h"
 #include "src/kernel/activity/ExecImpl.hpp"
+#include "src/mc/mc_replay.hpp"
 #include "src/simix/smx_private.hpp"
 #include "src/surf/HostImpl.hpp"
 
@@ -290,13 +293,25 @@ bool is_maestro()
 
 void sleep_for(double duration)
 {
+  xbt_assert(std::isfinite(duration), "duration is not finite!");
+
   if (duration > 0) {
-    kernel::actor::ActorImpl* actor = SIMIX_process_self();
-    Actor::on_sleep(*actor->ciface());
+    kernel::actor::ActorImpl* issuer = SIMIX_process_self();
+    Actor::on_sleep(*issuer->ciface());
+
+    simix::simcall_blocking([issuer, duration]() {
+      if (MC_is_active() || MC_record_replay_is_active()) {
+        MC_process_clock_add(issuer, duration);
+        issuer->simcall_answer();
+        return;
+      }
+      smx_activity_t sync = issuer->sleep(duration);
+      sync->simcalls_.push_back(&issuer->simcall);
+      issuer->waiting_synchro = sync;
 
-    simcall_process_sleep(duration);
+    });
 
-    Actor::on_wake_up(*actor->ciface());
+    Actor::on_wake_up(*issuer->ciface());
   }
 }
 
index 010360d..e2a4e63 100644 (file)
@@ -58,22 +58,10 @@ void simcall_process_suspend(smx_actor_t process)
   simcall_BODY_process_suspend(process);
 }
 
-/**
- * @ingroup simix_process_management
- * @brief Creates a new sleep SIMIX synchro.
- *
- * This function creates a SURF action and allocates the data necessary
- * to create the SIMIX synchro. It can raise a HostFailureException if the
- * host crashed. The default SIMIX name of the synchro is "sleep".
- *
- *   @param duration Time duration of the sleep.
- *   @return A result telling whether the sleep was successful
- */
 e_smx_state_t simcall_process_sleep(double duration)
 {
-  /* checking for infinite values */
-  xbt_assert(std::isfinite(duration), "duration is not finite!");
-  return (e_smx_state_t) simcall_BODY_process_sleep(duration);
+  SIMIX_process_self()->sleep(duration);
+  return SIMIX_DONE;
 }
 
 /**
index 5fe37d3..ea7db0f 100644 (file)
@@ -28,31 +28,6 @@ static inline void simcall_process_suspend__set__process(smx_simcall_t simcall,
   simgrid::simix::marshal<smx_actor_t>(simcall->args[0], arg);
 }
 
-static inline double simcall_process_sleep__get__duration(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal<double>(simcall->args[0]);
-}
-static inline double simcall_process_sleep__getraw__duration(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal_raw<double>(simcall->args[0]);
-}
-static inline void simcall_process_sleep__set__duration(smx_simcall_t simcall, double arg)
-{
-  simgrid::simix::marshal<double>(simcall->args[0], arg);
-}
-static inline int simcall_process_sleep__get__result(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal<int>(simcall->result);
-}
-static inline int simcall_process_sleep__getraw__result(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal_raw<int>(simcall->result);
-}
-static inline void simcall_process_sleep__set__result(smx_simcall_t simcall, int result)
-{
-  simgrid::simix::marshal<int>(simcall->result, result);
-}
-
 static inline simgrid::kernel::activity::ExecImpl* simcall_execution_wait__get__execution(smx_simcall_t simcall)
 {
   return simgrid::simix::unmarshal<simgrid::kernel::activity::ExecImpl*>(simcall->args[0]);
@@ -1038,7 +1013,6 @@ static inline void simcall_run_blocking__set__code(smx_simcall_t simcall, std::f
 /* The prototype of all simcall handlers, automatically generated for you */
 
 XBT_PRIVATE void simcall_HANDLER_process_suspend(smx_simcall_t simcall, smx_actor_t process);
-XBT_PRIVATE void simcall_HANDLER_process_sleep(smx_simcall_t simcall, double duration);
 XBT_PRIVATE void simcall_HANDLER_execution_wait(smx_simcall_t simcall, simgrid::kernel::activity::ExecImpl* execution);
 XBT_PRIVATE void simcall_HANDLER_execution_waitany_for(smx_simcall_t simcall, simgrid::kernel::activity::ExecImpl** execs, size_t count, double timeout);
 XBT_PRIVATE void simcall_HANDLER_execution_test(smx_simcall_t simcall, simgrid::kernel::activity::ExecImpl* execution);
index 8239a76..e5d44ad 100644 (file)
@@ -46,13 +46,6 @@ inline static void simcall_BODY_process_suspend(smx_actor_t process)
   return simcall<void, smx_actor_t>(SIMCALL_PROCESS_SUSPEND, process);
 }
 
-inline static int simcall_BODY_process_sleep(double duration)
-{
-  if (0) /* Go to that function to follow the code flow through the simcall barrier */
-    simcall_HANDLER_process_sleep(&SIMIX_process_self()->simcall, duration);
-  return simcall<int, double>(SIMCALL_PROCESS_SLEEP, duration);
-}
-
 inline static int simcall_BODY_execution_wait(simgrid::kernel::activity::ExecImpl* execution)
 {
   if (0) /* Go to that function to follow the code flow through the simcall barrier */
index 0d9f34f..8a477ff 100644 (file)
@@ -20,7 +20,6 @@
 typedef enum {
   SIMCALL_NONE,
   SIMCALL_PROCESS_SUSPEND,
-  SIMCALL_PROCESS_SLEEP,
   SIMCALL_EXECUTION_WAIT,
   SIMCALL_EXECUTION_WAITANY_FOR,
   SIMCALL_EXECUTION_TEST,
index 981f3b9..6b68380 100644 (file)
@@ -27,7 +27,6 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_popping);
 const char* simcall_names[] = {
     "SIMCALL_NONE",
     "SIMCALL_PROCESS_SUSPEND",
-    "SIMCALL_PROCESS_SLEEP",
     "SIMCALL_EXECUTION_WAIT",
     "SIMCALL_EXECUTION_WAITANY_FOR",
     "SIMCALL_EXECUTION_TEST",
@@ -67,10 +66,6 @@ void simgrid::kernel::actor::ActorImpl::simcall_handle(int value) {
       simcall_HANDLER_process_suspend(&simcall, simgrid::simix::unmarshal<smx_actor_t>(simcall.args[0]));
       break;
 
-    case SIMCALL_PROCESS_SLEEP:
-      simcall_HANDLER_process_sleep(&simcall, simgrid::simix::unmarshal<double>(simcall.args[0]));
-      break;
-
     case SIMCALL_EXECUTION_WAIT:
       simcall_HANDLER_execution_wait(&simcall, simgrid::simix::unmarshal<simgrid::kernel::activity::ExecImpl*>(simcall.args[0]));
       break;
index 5bbbaec..6d264cb 100644 (file)
@@ -36,7 +36,6 @@
 # ./include/simgrid/simix.h (otherwise you will get a warning at compile time)
 
 void process_suspend(smx_actor_t process) [[block]];
-int  process_sleep(double duration) [[block]];
 
 int           execution_wait(simgrid::kernel::activity::ExecImpl* execution) [[block]];
 int           execution_waitany_for(simgrid::kernel::activity::ExecImpl** execs, size_t count, double timeout) [[block]];