From: Frederic Suter Date: Fri, 21 Jul 2017 09:00:59 +0000 (+0200) Subject: modernize two more simcalls X-Git-Tag: v3_17~337 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/84a6e9061ba0240331de47f1de4207ac67875f77 modernize two more simcalls --- diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index d0fa5c4a6b..a9ebe7034d 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -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); diff --git a/src/msg/msg_process.cpp b/src/msg/msg_process.cpp index 3aa62d6716..8bbc1a7e53 100644 --- a/src/msg/msg_process.cpp +++ b/src/msg/msg_process.cpp @@ -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 diff --git a/src/simix/ActorImpl.cpp b/src/simix/ActorImpl.cpp index afdedc1bc5..a33bfacc73 100644 --- a/src/simix/ActorImpl.cpp +++ b/src/simix/ActorImpl.cpp @@ -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 diff --git a/src/simix/libsmx.cpp b/src/simix/libsmx.cpp index 993d28da4a..d525579e9f 100644 --- a/src/simix/libsmx.cpp +++ b/src/simix/libsmx.cpp @@ -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(); }); } /** diff --git a/src/simix/popping_accessors.h b/src/simix/popping_accessors.h index 28975af8dd..d59feb7452 100644 --- a/src/simix/popping_accessors.h +++ b/src/simix/popping_accessors.h @@ -431,30 +431,6 @@ static inline void simcall_process_on_exit__set__data(smx_simcall_t simcall, voi simgrid::simix::marshal(simcall->args[2], arg); } -static inline smx_actor_t simcall_process_restart__get__process(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal(simcall->args[0]); -} -static inline smx_actor_t simcall_process_restart__getraw__process(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal_raw(simcall->args[0]); -} -static inline void simcall_process_restart__set__process(smx_simcall_t simcall, smx_actor_t arg) -{ - simgrid::simix::marshal(simcall->args[0], arg); -} -static inline smx_actor_t simcall_process_restart__get__result(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal(simcall->result); -} -static inline smx_actor_t simcall_process_restart__getraw__result(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal_raw(simcall->result); -} -static inline void simcall_process_restart__set__result(smx_simcall_t simcall, smx_actor_t result){ - simgrid::simix::marshal(simcall->result, result); -} - static inline smx_mailbox_t simcall_comm_iprobe__get__mbox(smx_simcall_t simcall) { return simgrid::simix::unmarshal(simcall->args[0]); @@ -1134,18 +1110,6 @@ static inline void simcall_comm_testany__set__result(smx_simcall_t simcall, int simgrid::simix::marshal(simcall->result, result); } -static inline smx_mutex_t simcall_mutex_init__get__result(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal(simcall->result); -} -static inline smx_mutex_t simcall_mutex_init__getraw__result(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal_raw(simcall->result); -} -static inline void simcall_mutex_init__set__result(smx_simcall_t simcall, smx_mutex_t result){ - simgrid::simix::marshal(simcall->result, result); -} - static inline smx_mutex_t simcall_mutex_lock__get__mutex(smx_simcall_t simcall) { return simgrid::simix::unmarshal(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 execution); -XBT_PRIVATE smx_actor_t simcall_HANDLER_process_restart(smx_simcall_t simcall, smx_actor_t process); XBT_PRIVATE boost::intrusive_ptr 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* 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); diff --git a/src/simix/popping_bodies.cpp b/src/simix/popping_bodies.cpp index 88b4533e06..71639ffc67 100644 --- a/src/simix/popping_bodies.cpp +++ b/src/simix/popping_bodies.cpp @@ -136,12 +136,6 @@ inline static void simcall_BODY_process_on_exit(smx_actor_t process, int_f_pvoid return simcall(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(SIMCALL_PROCESS_RESTART, process); - } - inline static boost::intrusive_ptr 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(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); diff --git a/src/simix/popping_enum.h b/src/simix/popping_enum.h index 0499e1c59d..49a8625e31 100644 --- a/src/simix/popping_enum.h +++ b/src/simix/popping_enum.h @@ -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, diff --git a/src/simix/popping_generated.cpp b/src/simix/popping_generated.cpp index 69010c2676..916476a210 100644 --- a/src/simix/popping_generated.cpp +++ b/src/simix/popping_generated.cpp @@ -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(simcall->result, simcall_HANDLER_process_restart(simcall, simgrid::simix::unmarshal(simcall->args[0]))); - SIMIX_simcall_answer(simcall); - break; - case SIMCALL_COMM_IPROBE: simgrid::simix::marshal>( simcall->result, simcall_HANDLER_comm_iprobe(simcall, simgrid::simix::unmarshal(simcall->args[0]), @@ -234,11 +227,6 @@ case SIMCALL_COMM_TESTANY: simgrid::simix::unmarshal(simcall->args[1])); break; -case SIMCALL_MUTEX_INIT: - simgrid::simix::marshal(simcall->result, simcall_HANDLER_mutex_init(simcall)); - SIMIX_simcall_answer(simcall); - break; - case SIMCALL_MUTEX_LOCK: simcall_HANDLER_mutex_lock(simcall, simgrid::simix::unmarshal(simcall->args[0])); break; diff --git a/src/simix/simcalls.in b/src/simix/simcalls.in index 1dccd291a9..50e4c30ccb 100644 --- a/src/simix/simcalls.in +++ b/src/simix/simcalls.in @@ -50,7 +50,6 @@ void execution_set_bound(boost::intrusive_ptr 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 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 comm) [[block]]; int comm_testany(boost::intrusive_ptr* 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); diff --git a/src/simix/smx_synchro.cpp b/src/simix/smx_synchro.cpp index 93f437b012..a5cfc25065 100644 --- a/src/simix/smx_synchro.cpp +++ b/src/simix/smx_synchro.cpp @@ -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)