Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
simcall to kernelImmediate
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 5 Jul 2017 21:39:51 +0000 (23:39 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 5 Jul 2017 21:56:24 +0000 (23:56 +0200)
include/simgrid/s4u/Actor.hpp
include/simgrid/simix.h
src/msg/msg_process.cpp
src/s4u/s4u_actor.cpp
src/simix/ActorImpl.cpp
src/simix/libsmx.cpp
src/simix/popping_accessors.h
src/simix/popping_bodies.cpp
src/simix/popping_enum.h
src/simix/popping_generated.cpp
src/simix/simcalls.in

index f8febaa..a61160f 100644 (file)
@@ -338,7 +338,7 @@ template <class Rep, class Period> inline void sleep_for(std::chrono::duration<R
   /** @brief Resume the actor. */
   XBT_PUBLIC(void) resume();
 
-  XBT_PUBLIC(int) isSuspended();
+  XBT_PUBLIC(bool) isSuspended();
 
   /** @brief kill the actor. */
   XBT_PUBLIC(void) kill();
index a544922..dae571e 100644 (file)
@@ -219,8 +219,6 @@ XBT_PUBLIC(void) simcall_process_resume(smx_actor_t process);
 /* Getters and Setters */
 XBT_PUBLIC(int) simcall_process_count();
 XBT_PUBLIC(void) simcall_process_set_data(smx_actor_t process, void *data);
-XBT_PUBLIC(void) simcall_process_set_host(smx_actor_t process, sg_host_t dest);
-XBT_PUBLIC(int) simcall_process_is_suspended(smx_actor_t process);
 XBT_PUBLIC(xbt_dict_t) simcall_process_get_properties(smx_actor_t host);
 XBT_PUBLIC(void) simcall_process_set_kill_time(smx_actor_t process, double kill_time);
 XBT_PUBLIC(double) simcall_process_get_kill_time(smx_actor_t process);
index e8e8b2f..ba8894b 100644 (file)
@@ -212,7 +212,7 @@ msg_error_t MSG_process_join(msg_process_t process, double timeout){
 msg_error_t MSG_process_migrate(msg_process_t process, msg_host_t host)
 {
   TRACE_msg_process_change_host(process, MSG_process_get_host(process), host);
-  simcall_process_set_host(process->getImpl(), host);
+  process->migrate(host);
   return MSG_OK;
 }
 
@@ -443,7 +443,7 @@ msg_error_t MSG_process_resume(msg_process_t process)
  */
 int MSG_process_is_suspended(msg_process_t process)
 {
-  return simcall_process_is_suspended(process->getImpl());
+  return process->isSuspended();
 }
 
 smx_context_t MSG_process_get_smx_ctx(msg_process_t process) {
index f9b2cf9..bfc88d3 100644 (file)
@@ -72,7 +72,7 @@ void Actor::onExit(int_f_pvoid_pvoid_t fun, void* data)
 
 void Actor::migrate(Host* new_host)
 {
-  simcall_process_set_host(pimpl_, new_host);
+  simgrid::simix::kernelImmediate([this, new_host]() { pimpl_->new_host = new_host; });
 }
 
 s4u::Host* Actor::host()
@@ -117,7 +117,7 @@ void Actor::resume()
 
 int Actor::isSuspended()
 {
-  return simcall_process_is_suspended(pimpl_);
+  return simgrid::simix::kernelImmediate([this]() { return pimpl_->suspended; });
 }
 
 void Actor::setKillTime(double time) {
@@ -299,9 +299,10 @@ void resume()
   simcall_process_resume(SIMIX_process_self());
 }
 
-int isSuspended()
+bool isSuspended()
 {
-  return simcall_process_is_suspended(SIMIX_process_self());
+  smx_actor_t process = SIMIX_process_self();
+  return simgrid::simix::kernelImmediate([process] { return process->suspended; });
 }
 
 void kill()
@@ -316,7 +317,8 @@ void onExit(int_f_pvoid_pvoid_t fun, void* data)
 
 void migrate(Host* new_host)
 {
-  simcall_process_set_host(SIMIX_process_self(), new_host);
+  smx_actor_t process = SIMIX_process_self();
+  simgrid::simix::kernelImmediate([process, new_host] { process->new_host = new_host; });
 }
 }
 }
index d0f4ae7..fab8b8c 100644 (file)
@@ -529,11 +529,6 @@ void SIMIX_process_killall(smx_actor_t issuer, int reset_pid)
   SIMIX_process_empty_trash();
 }
 
-void simcall_HANDLER_process_set_host(smx_simcall_t simcall, smx_actor_t process, sg_host_t dest)
-{
-  process->new_host = dest;
-}
-
 void SIMIX_process_change_host(smx_actor_t process, sg_host_t dest)
 {
   xbt_assert((process != nullptr), "Invalid parameters");
index 8a0d0fc..0e3ba0c 100644 (file)
@@ -189,20 +189,6 @@ void simcall_process_cleanup(smx_actor_t process)
   simcall_BODY_process_cleanup(process);
 }
 
-/**
- * \ingroup simix_process_management
- * \brief Migrates an agent to another location.
- *
- * This function changes the value of the host on which \a process is running.
- *
- * \param process the process to migrate
- * \param dest name of the new host
- */
-void simcall_process_set_host(smx_actor_t process, sg_host_t dest)
-{
-  simcall_BODY_process_set_host(process, dest);
-}
-
 void simcall_process_join(smx_actor_t process, double timeout)
 {
   simcall_BODY_process_join(process, timeout);
@@ -283,19 +269,6 @@ double simcall_process_get_kill_time(smx_actor_t process) {
   return SIMIX_timer_get_date(process->kill_timer);
 }
 
-/**
- * \ingroup simix_process_management
- * \brief Returns true if the process is suspended .
- *
- * This checks whether a process is suspended or not by inspecting the task on which it was waiting for the completion.
- * \param process SIMIX process
- * \return 1, if the process is suspended, else 0.
- */
-int simcall_process_is_suspended(smx_actor_t process)
-{
-  return simcall_BODY_process_is_suspended(process);
-}
-
 /**
  * \ingroup simix_process_management
  * \brief Return the properties
index 8f517f0..45ed932 100644 (file)
@@ -80,55 +80,6 @@ static inline void simcall_process_resume__set__process(smx_simcall_t simcall, s
   simgrid::simix::marshal<smx_actor_t>(simcall->args[0], arg);
 }
 
-static inline smx_actor_t simcall_process_set_host__get__process(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal<smx_actor_t>(simcall->args[0]);
-}
-static inline smx_actor_t simcall_process_set_host__getraw__process(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal_raw<smx_actor_t>(simcall->args[0]);
-}
-static inline void simcall_process_set_host__set__process(smx_simcall_t simcall, smx_actor_t arg)
-{
-  simgrid::simix::marshal<smx_actor_t>(simcall->args[0], arg);
-}
-static inline sg_host_t simcall_process_set_host__get__dest(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal<sg_host_t>(simcall->args[1]);
-}
-static inline sg_host_t simcall_process_set_host__getraw__dest(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal_raw<sg_host_t>(simcall->args[1]);
-}
-static inline void simcall_process_set_host__set__dest(smx_simcall_t simcall, sg_host_t arg)
-{
-  simgrid::simix::marshal<sg_host_t>(simcall->args[1], arg);
-}
-
-static inline smx_actor_t simcall_process_is_suspended__get__process(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal<smx_actor_t>(simcall->args[0]);
-}
-static inline smx_actor_t simcall_process_is_suspended__getraw__process(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal_raw<smx_actor_t>(simcall->args[0]);
-}
-static inline void simcall_process_is_suspended__set__process(smx_simcall_t simcall, smx_actor_t arg)
-{
-  simgrid::simix::marshal<smx_actor_t>(simcall->args[0], arg);
-}
-static inline int simcall_process_is_suspended__get__result(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal<int>(simcall->result);
-}
-static inline int simcall_process_is_suspended__getraw__result(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal_raw<int>(simcall->result);
-}
-static inline void simcall_process_is_suspended__set__result(smx_simcall_t simcall, int result){
-    simgrid::simix::marshal<int>(simcall->result, result);
-}
-
 static inline smx_actor_t simcall_process_join__get__process(smx_simcall_t simcall)
 {
   return simgrid::simix::unmarshal<smx_actor_t>(simcall->args[0]);
@@ -1817,7 +1768,6 @@ static inline void simcall_run_blocking__set__code(smx_simcall_t simcall, std::f
 XBT_PRIVATE void simcall_HANDLER_process_kill(smx_simcall_t simcall, smx_actor_t process);
 XBT_PRIVATE void simcall_HANDLER_process_killall(smx_simcall_t simcall, int reset_pid);
 XBT_PRIVATE void simcall_HANDLER_process_suspend(smx_simcall_t simcall, smx_actor_t process);
-XBT_PRIVATE void simcall_HANDLER_process_set_host(smx_simcall_t simcall, smx_actor_t process, sg_host_t dest);
 XBT_PRIVATE void simcall_HANDLER_process_join(smx_simcall_t simcall, smx_actor_t process, double timeout);
 XBT_PRIVATE void simcall_HANDLER_process_sleep(smx_simcall_t simcall, double duration);
 XBT_PRIVATE boost::intrusive_ptr<simgrid::kernel::activity::ExecImpl>
index afb58a3..a156c36 100644 (file)
@@ -66,18 +66,6 @@ inline static void simcall_BODY_process_resume(smx_actor_t process) {
     return simcall<void, smx_actor_t>(SIMCALL_PROCESS_RESUME, process);
   }
 
-inline static void simcall_BODY_process_set_host(smx_actor_t process, sg_host_t dest) {
-    /* Go to that function to follow the code flow through the simcall barrier */
-    if (0) simcall_HANDLER_process_set_host(&SIMIX_process_self()->simcall, process, dest);
-    return simcall<void, smx_actor_t, sg_host_t>(SIMCALL_PROCESS_SET_HOST, process, dest);
-  }
-
-inline static int simcall_BODY_process_is_suspended(smx_actor_t process) {
-    /* Go to that function to follow the code flow through the simcall barrier */
-    if (0) SIMIX_process_is_suspended(process);
-    return simcall<int, smx_actor_t>(SIMCALL_PROCESS_IS_SUSPENDED, process);
-  }
-
 inline static int simcall_BODY_process_join(smx_actor_t process, double timeout) {
     /* Go to that function to follow the code flow through the simcall barrier */
     if (0) simcall_HANDLER_process_join(&SIMIX_process_self()->simcall, process, timeout);
index 21c5fd3..3ea2507 100644 (file)
@@ -24,8 +24,6 @@ typedef enum {
   SIMCALL_PROCESS_CLEANUP,
   SIMCALL_PROCESS_SUSPEND,
   SIMCALL_PROCESS_RESUME,
-  SIMCALL_PROCESS_SET_HOST,
-  SIMCALL_PROCESS_IS_SUSPENDED,
   SIMCALL_PROCESS_JOIN,
   SIMCALL_PROCESS_SLEEP,
   SIMCALL_EXECUTION_START,
index 262e7e0..3135e6f 100644 (file)
@@ -30,8 +30,6 @@ const char* simcall_names[] = {
     "SIMCALL_PROCESS_CLEANUP",
     "SIMCALL_PROCESS_SUSPEND",
     "SIMCALL_PROCESS_RESUME",
-    "SIMCALL_PROCESS_SET_HOST",
-    "SIMCALL_PROCESS_IS_SUSPENDED",
     "SIMCALL_PROCESS_JOIN",
     "SIMCALL_PROCESS_SLEEP",
     "SIMCALL_EXECUTION_START",
@@ -112,16 +110,6 @@ case SIMCALL_PROCESS_RESUME:
       SIMIX_simcall_answer(simcall);
       break;
 
-case SIMCALL_PROCESS_SET_HOST:
-      simcall_HANDLER_process_set_host(simcall, simgrid::simix::unmarshal<smx_actor_t>(simcall->args[0]), simgrid::simix::unmarshal<sg_host_t>(simcall->args[1]));
-      SIMIX_simcall_answer(simcall);
-      break;
-
-case SIMCALL_PROCESS_IS_SUSPENDED:
-      simgrid::simix::marshal<int>(simcall->result, SIMIX_process_is_suspended(simgrid::simix::unmarshal<smx_actor_t>(simcall->args[0])));
-      SIMIX_simcall_answer(simcall);
-      break;
-
 case SIMCALL_PROCESS_JOIN:
       simcall_HANDLER_process_join(simcall, simgrid::simix::unmarshal<smx_actor_t>(simcall->args[0]), simgrid::simix::unmarshal<double>(simcall->args[1]));
       break;
index e3cce1a..22c455e 100644 (file)
 # int foo(int x, int y) [[nohandler]];
 # int foo(int x, int y) [[block, nohandler]];
 #
-# The `block` attribut is used for calls which do not return in the same
+# The `block` attribute is used for calls which do not return in the same
 # scheduling round. The answer requires some interaction with SURF,
-# even if this can still occure at the same timestamp under some
-# circonstances (eg if the surf_action cannot start because of resources
+# even if this can still occur at the same timestamp under some
+# circumstances (eg if the surf_action cannot start because of resources
 # that are down) examples: things that last some time (communicate, execute,
 # mutex_lock).
 #
 # by the kernel. 
 # The only remaining use of that mechanism is to add the caller
 # identity as a parameter of internal call, but that could be
-# automatized too (eg by having a special parameter type called "self")
+# automated too (eg by having a special parameter type called "self")
 
 # Please note that in addition to completing this file with your new simcall,
 # you should complete the libsmx.c file by adding the corresponding function
-# (aka. stub). Anyway, if you omit to do it, the invocation of ./simcalls.py will notify you ;)
+# (a.k.a. stub). Anyway, if you omit to do it, the invocation of ./simcalls.py will notify you ;)
 # If you want to remove an handler, it is important to remove although
 # the corresponding code (simcall_HANDLER_name_of_simcall(xxx) (note that comment the code 
 # is not sufficient, the python script does not check whether the code is commented or not).
 # Last but not the least, you should declare the new simix call in
-# ./include/simgrid/simix.h (otherwise you will get a warning at the
-# compilation time)
+# ./include/simgrid/simix.h (otherwise you will get a warning at compile time)
 
 void process_kill(smx_actor_t process);
 void process_killall(int reset_pid);
 void process_cleanup(smx_actor_t process) [[nohandler]];
 void process_suspend(smx_actor_t process) [[block]];
 void process_resume(smx_actor_t process) [[nohandler]];
-void process_set_host(smx_actor_t process, sg_host_t dest);
-int  process_is_suspended(smx_actor_t process) [[nohandler]];
 int  process_join(smx_actor_t process, double timeout) [[block]];
 int  process_sleep(double duration) [[block]];