Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
modernize two more simcalls
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Fri, 21 Jul 2017 09:00:59 +0000 (11:00 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Fri, 21 Jul 2017 09:34:46 +0000 (11:34 +0200)
include/simgrid/simix.h
src/msg/msg_process.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
src/simix/smx_synchro.cpp

index d0fa5c4..a9ebe70 100644 (file)
@@ -219,7 +219,6 @@ XBT_PUBLIC(void) simcall_process_set_data(smx_actor_t process, void *data);
 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(void) simcall_process_on_exit(smx_actor_t process, int_f_pvoid_pvoid_t fun, void *data);
-XBT_PUBLIC(smx_actor_t) simcall_process_restart(smx_actor_t process);
 XBT_PUBLIC(void) simcall_process_join(smx_actor_t process, double timeout);
 /* Sleep control */
 XBT_PUBLIC(e_smx_state_t) simcall_process_sleep(double duration);
index 3aa62d6..8bbc1a7 100644 (file)
@@ -471,7 +471,8 @@ XBT_PUBLIC(void) MSG_process_auto_restart_set(msg_process_t process, int auto_re
  * \brief Restarts a process from the beginning.
  */
 XBT_PUBLIC(msg_process_t) MSG_process_restart(msg_process_t process) {
-  return simcall_process_restart(process->getImpl())->ciface();
+  return simgrid::simix::kernelImmediate(
+      [process]() { return process->getImpl()->restart(process->getImpl())->ciface(); });
 }
 
 /** @ingroup m_process_management
index afdedc1..a33bfac 100644 (file)
@@ -755,8 +755,7 @@ void SIMIX_process_sleep_destroy(smx_activity_t synchro)
 /**
  * \brief Calling this function makes the process to yield.
  *
- * Only the current process can call this function, giving back the control to
- * maestro.
+ * Only the current process can call this function, giving back the control to maestro.
  *
  * \param self the current process
  */
@@ -815,17 +814,13 @@ void SIMIX_process_exception_terminate(xbt_ex_t * e)
   xbt_abort();
 }
 
-/**
- * \brief Returns the list of processes to run.
- */
+/** @brief Returns the list of processes to run. */
 xbt_dynar_t SIMIX_process_get_runnable()
 {
   return simix_global->process_to_run;
 }
 
-/**
- * \brief Returns the process from PID.
- */
+/** @brief Returns the process from PID. */
 smx_actor_t SIMIX_process_from_PID(aid_t PID)
 {
   if (simix_global->process_list.find(PID) == simix_global->process_list.end())
@@ -862,17 +857,12 @@ void SIMIX_process_on_exit(smx_actor_t process, int_f_pvoid_pvoid_t fun, void *d
 
 /**
  * \brief Sets the auto-restart status of the process.
- * If set to 1, the process will be automatically restarted when its host
- * comes back.
+ * If set to 1, the process will be automatically restarted when its host comes back.
  */
 void SIMIX_process_auto_restart_set(smx_actor_t process, int auto_restart) {
   process->auto_restart = auto_restart;
 }
 
-smx_actor_t simcall_HANDLER_process_restart(smx_simcall_t simcall, smx_actor_t process) {
-  return process->restart(simcall->issuer);
-}
-
 /** @brief Restart a process, starting it again from the beginning. */
 /**
  * \ingroup simix_process_management
index 993d28d..d525579 100644 (file)
@@ -265,14 +265,6 @@ XBT_PUBLIC(void) simcall_process_on_exit(smx_actor_t process, int_f_pvoid_pvoid_
   simcall_BODY_process_on_exit(process, fun, data);
 }
 
-/**
- * \ingroup simix_process_management
- * \brief Restarts the process, killing it and starting it again from scratch.
- */
-XBT_PUBLIC(smx_actor_t) simcall_process_restart(smx_actor_t process)
-{
-  return (smx_actor_t) simcall_BODY_process_restart(process);
-}
 /**
  * \ingroup simix_process_management
  * \brief Creates a new sleep SIMIX synchro.
@@ -459,7 +451,7 @@ smx_mutex_t simcall_mutex_init()
     fprintf(stderr,"You must run MSG_init before using MSG\n"); // We can't use xbt_die since we may get there before the initialization
     xbt_abort();
   }
-  return simcall_BODY_mutex_init();
+  return simgrid::simix::kernelImmediate([] { return new simgrid::simix::MutexImpl(); });
 }
 
 /**
index 28975af..d59feb7 100644 (file)
@@ -431,30 +431,6 @@ static inline void simcall_process_on_exit__set__data(smx_simcall_t simcall, voi
   simgrid::simix::marshal<void*>(simcall->args[2], arg);
 }
 
-static inline smx_actor_t simcall_process_restart__get__process(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal<smx_actor_t>(simcall->args[0]);
-}
-static inline smx_actor_t simcall_process_restart__getraw__process(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal_raw<smx_actor_t>(simcall->args[0]);
-}
-static inline void simcall_process_restart__set__process(smx_simcall_t simcall, smx_actor_t arg)
-{
-  simgrid::simix::marshal<smx_actor_t>(simcall->args[0], arg);
-}
-static inline smx_actor_t simcall_process_restart__get__result(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal<smx_actor_t>(simcall->result);
-}
-static inline smx_actor_t simcall_process_restart__getraw__result(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal_raw<smx_actor_t>(simcall->result);
-}
-static inline void simcall_process_restart__set__result(smx_simcall_t simcall, smx_actor_t result){
-    simgrid::simix::marshal<smx_actor_t>(simcall->result, result);
-}
-
 static inline smx_mailbox_t simcall_comm_iprobe__get__mbox(smx_simcall_t simcall)
 {
   return simgrid::simix::unmarshal<smx_mailbox_t>(simcall->args[0]);
@@ -1134,18 +1110,6 @@ static inline void simcall_comm_testany__set__result(smx_simcall_t simcall, int
     simgrid::simix::marshal<int>(simcall->result, result);
 }
 
-static inline smx_mutex_t simcall_mutex_init__get__result(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal<smx_mutex_t>(simcall->result);
-}
-static inline smx_mutex_t simcall_mutex_init__getraw__result(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal_raw<smx_mutex_t>(simcall->result);
-}
-static inline void simcall_mutex_init__set__result(smx_simcall_t simcall, smx_mutex_t result){
-    simgrid::simix::marshal<smx_mutex_t>(simcall->result, result);
-}
-
 static inline smx_mutex_t simcall_mutex_lock__get__mutex(smx_simcall_t simcall)
 {
   return simgrid::simix::unmarshal<smx_mutex_t>(simcall->args[0]);
@@ -1580,7 +1544,6 @@ simcall_HANDLER_execution_start(smx_simcall_t simcall, const char* name, double
 XBT_PRIVATE void
 simcall_HANDLER_execution_wait(smx_simcall_t simcall,
                                boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> execution);
-XBT_PRIVATE smx_actor_t simcall_HANDLER_process_restart(smx_simcall_t simcall, smx_actor_t process);
 XBT_PRIVATE boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl>
 simcall_HANDLER_comm_iprobe(smx_simcall_t simcall, smx_mailbox_t mbox, int type, simix_match_func_t match_fun,
                             void* data);
@@ -1604,7 +1567,6 @@ XBT_PRIVATE void simcall_HANDLER_comm_test(smx_simcall_t simcall,
 XBT_PRIVATE void simcall_HANDLER_comm_testany(smx_simcall_t simcall,
                                               boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl>* comms,
                                               size_t count);
-XBT_PRIVATE smx_mutex_t simcall_HANDLER_mutex_init(smx_simcall_t simcall);
 XBT_PRIVATE void simcall_HANDLER_mutex_lock(smx_simcall_t simcall, smx_mutex_t mutex);
 XBT_PRIVATE int simcall_HANDLER_mutex_trylock(smx_simcall_t simcall, smx_mutex_t mutex);
 XBT_PRIVATE void simcall_HANDLER_cond_wait(smx_simcall_t simcall, smx_cond_t cond, smx_mutex_t mutex);
index 88b4533..71639ff 100644 (file)
@@ -136,12 +136,6 @@ inline static void simcall_BODY_process_on_exit(smx_actor_t process, int_f_pvoid
     return simcall<void, smx_actor_t, int_f_pvoid_pvoid_t, void*>(SIMCALL_PROCESS_ON_EXIT, process, fun, data);
   }
 
-inline static smx_actor_t simcall_BODY_process_restart(smx_actor_t process) {
-    /* Go to that function to follow the code flow through the simcall barrier */
-    if (0) simcall_HANDLER_process_restart(&SIMIX_process_self()->simcall, process);
-    return simcall<smx_actor_t, smx_actor_t>(SIMCALL_PROCESS_RESTART, process);
-  }
-
   inline static boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl>
   simcall_BODY_comm_iprobe(smx_mailbox_t mbox, int type, simix_match_func_t match_fun, void* data)
   {
@@ -219,12 +213,6 @@ inline static int simcall_BODY_comm_waitany(xbt_dynar_t comms, double timeout) {
                                                                                                 comms, count);
   }
 
-inline static smx_mutex_t simcall_BODY_mutex_init() {
-    /* Go to that function to follow the code flow through the simcall barrier */
-    if (0) simcall_HANDLER_mutex_init(&SIMIX_process_self()->simcall);
-    return simcall<smx_mutex_t>(SIMCALL_MUTEX_INIT);
-  }
-
 inline static void simcall_BODY_mutex_lock(smx_mutex_t mutex) {
     /* Go to that function to follow the code flow through the simcall barrier */
     if (0) simcall_HANDLER_mutex_lock(&SIMIX_process_self()->simcall, mutex);
index 0499e1c..49a8625 100644 (file)
@@ -32,7 +32,6 @@ typedef enum {
   SIMCALL_EXECUTION_SET_BOUND,
   SIMCALL_EXECUTION_WAIT,
   SIMCALL_PROCESS_ON_EXIT,
-  SIMCALL_PROCESS_RESTART,
   SIMCALL_COMM_IPROBE,
   SIMCALL_COMM_SEND,
   SIMCALL_COMM_ISEND,
@@ -42,7 +41,6 @@ typedef enum {
   SIMCALL_COMM_WAIT,
   SIMCALL_COMM_TEST,
   SIMCALL_COMM_TESTANY,
-  SIMCALL_MUTEX_INIT,
   SIMCALL_MUTEX_LOCK,
   SIMCALL_MUTEX_TRYLOCK,
   SIMCALL_COND_INIT,
index 69010c2..916476a 100644 (file)
@@ -38,7 +38,6 @@ const char* simcall_names[] = {
     "SIMCALL_EXECUTION_SET_BOUND",
     "SIMCALL_EXECUTION_WAIT",
     "SIMCALL_PROCESS_ON_EXIT",
-    "SIMCALL_PROCESS_RESTART",
     "SIMCALL_COMM_IPROBE",
     "SIMCALL_COMM_SEND",
     "SIMCALL_COMM_ISEND",
@@ -48,7 +47,6 @@ const char* simcall_names[] = {
     "SIMCALL_COMM_WAIT",
     "SIMCALL_COMM_TEST",
     "SIMCALL_COMM_TESTANY",
-    "SIMCALL_MUTEX_INIT",
     "SIMCALL_MUTEX_LOCK",
     "SIMCALL_MUTEX_TRYLOCK",
     "SIMCALL_COND_INIT",
@@ -160,11 +158,6 @@ case SIMCALL_PROCESS_ON_EXIT:
       SIMIX_simcall_answer(simcall);
       break;
 
-case SIMCALL_PROCESS_RESTART:
-      simgrid::simix::marshal<smx_actor_t>(simcall->result, simcall_HANDLER_process_restart(simcall, simgrid::simix::unmarshal<smx_actor_t>(simcall->args[0])));
-      SIMIX_simcall_answer(simcall);
-      break;
-
 case SIMCALL_COMM_IPROBE:
   simgrid::simix::marshal<boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl>>(
       simcall->result, simcall_HANDLER_comm_iprobe(simcall, simgrid::simix::unmarshal<smx_mailbox_t>(simcall->args[0]),
@@ -234,11 +227,6 @@ case SIMCALL_COMM_TESTANY:
       simgrid::simix::unmarshal<size_t>(simcall->args[1]));
   break;
 
-case SIMCALL_MUTEX_INIT:
-      simgrid::simix::marshal<smx_mutex_t>(simcall->result, simcall_HANDLER_mutex_init(simcall));
-      SIMIX_simcall_answer(simcall);
-      break;
-
 case SIMCALL_MUTEX_LOCK:
       simcall_HANDLER_mutex_lock(simcall, simgrid::simix::unmarshal<smx_mutex_t>(simcall->args[0]));
       break;
index 1dccd29..50e4c30 100644 (file)
@@ -50,7 +50,6 @@ void          execution_set_bound(boost::intrusive_ptr<simgrid::kernel::activity
 int           execution_wait(boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> execution) [[block]];
 
 void          process_on_exit(smx_actor_t process, int_f_pvoid_pvoid_t fun, void* data) [[nohandler]];
-smx_actor_t   process_restart(smx_actor_t process);
 
 boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> comm_iprobe(smx_mailbox_t mbox, int type, simix_match_func_t match_fun, void* data);
 void           comm_send(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* src_buff, size_t src_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double timeout) [[block]];
@@ -62,7 +61,6 @@ void           comm_wait(boost::intrusive_ptr<simgrid::kernel::activity::Activit
 int            comm_test(boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> comm) [[block]];
 int            comm_testany(boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl>* comms, size_t count) [[block]];
 
-smx_mutex_t mutex_init();
 void        mutex_lock(smx_mutex_t mutex) [[block]];
 int         mutex_trylock(smx_mutex_t mutex);
 
index 93f437b..a5cfc25 100644 (file)
@@ -204,11 +204,6 @@ void SIMIX_mutex_unref(smx_mutex_t mutex)
     intrusive_ptr_release(mutex);
 }
 
-smx_mutex_t simcall_HANDLER_mutex_init(smx_simcall_t simcall)
-{
-  return new simgrid::simix::MutexImpl();
-}
-
 // Simcall handlers:
 
 void simcall_HANDLER_mutex_lock(smx_simcall_t simcall, smx_mutex_t mutex)