From: Martin Quinson Date: Mon, 16 Apr 2018 07:50:41 +0000 (+0200) Subject: modernize 2 simcalls in ConditionVariable X-Git-Tag: v3.20~419 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/8d01bd80335f89f2c28cbd1cc00094b5edd8d2de modernize 2 simcalls in ConditionVariable --- diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index 482973ae2a..d35a3be6bb 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -257,10 +257,8 @@ XBT_PUBLIC int simcall_mutex_trylock(smx_mutex_t mutex); XBT_PUBLIC void simcall_mutex_unlock(smx_mutex_t mutex); XBT_PUBLIC smx_cond_t simcall_cond_init(); -XBT_PUBLIC void simcall_cond_signal(smx_cond_t cond); XBT_PUBLIC void simcall_cond_wait(smx_cond_t cond, smx_mutex_t mutex); XBT_PUBLIC void simcall_cond_wait_timeout(smx_cond_t cond, smx_mutex_t mutex, double max_duration); -XBT_PUBLIC void simcall_cond_broadcast(smx_cond_t cond); XBT_PUBLIC void SIMIX_sem_destroy(smx_sem_t sem); XBT_PUBLIC void simcall_sem_acquire(smx_sem_t sem); diff --git a/src/kernel/activity/ConditionVariableImpl.cpp b/src/kernel/activity/ConditionVariableImpl.cpp index b08e892107..80aaae6197 100644 --- a/src/kernel/activity/ConditionVariableImpl.cpp +++ b/src/kernel/activity/ConditionVariableImpl.cpp @@ -152,13 +152,3 @@ void intrusive_ptr_release(simgrid::kernel::activity::ConditionVariableImpl* con } // namespace activity } // namespace kernel } - -XBT_PRIVATE void simcall_HANDLER_cond_signal(smx_simcall_t simcall, smx_cond_t cond) -{ - cond->signal(); -} - -XBT_PRIVATE void simcall_HANDLER_cond_broadcast(smx_simcall_t simcall, smx_cond_t cond) -{ - cond->broadcast(); -} diff --git a/src/kernel/activity/ConditionVariableImpl.hpp b/src/kernel/activity/ConditionVariableImpl.hpp index eeb95d126d..a41fa90007 100644 --- a/src/kernel/activity/ConditionVariableImpl.hpp +++ b/src/kernel/activity/ConditionVariableImpl.hpp @@ -36,8 +36,4 @@ private: } // namespace simgrid XBT_PRIVATE smx_cond_t SIMIX_cond_init(); -// simcall handlers -XBT_PRIVATE void simcall_HANDLER_cond_signal(smx_simcall_t simcall, smx_cond_t cond); -XBT_PRIVATE void simcall_HANDLER_cond_broadcast(smx_simcall_t simcall, smx_cond_t cond); - #endif diff --git a/src/s4u/s4u_conditionVariable.cpp b/src/s4u/s4u_conditionVariable.cpp index 0def488914..2881d9bf44 100644 --- a/src/s4u/s4u_conditionVariable.cpp +++ b/src/s4u/s4u_conditionVariable.cpp @@ -79,11 +79,11 @@ std::cv_status ConditionVariable::wait_until(std::unique_lock& lock, doub * Notify functions */ void ConditionVariable::notify_one() { - simcall_cond_signal(cond_); + simgrid::simix::kernelImmediate([this]() { cond_->signal(); }); } void ConditionVariable::notify_all() { - simcall_cond_broadcast(cond_); + simgrid::simix::kernelImmediate([this]() { cond_->broadcast(); }); } void intrusive_ptr_add_ref(ConditionVariable* cond) diff --git a/src/simix/libsmx.cpp b/src/simix/libsmx.cpp index 943902b52c..2ecba30dc4 100644 --- a/src/simix/libsmx.cpp +++ b/src/simix/libsmx.cpp @@ -490,15 +490,6 @@ smx_cond_t simcall_cond_init() return simcall_BODY_cond_init(); } -/** - * \ingroup simix_synchro_management - * - */ -void simcall_cond_signal(smx_cond_t cond) -{ - simcall_BODY_cond_signal(cond); -} - /** * \ingroup simix_synchro_management * @@ -518,15 +509,6 @@ void simcall_cond_wait_timeout(smx_cond_t cond, smx_mutex_t mutex, double timeou simcall_BODY_cond_wait_timeout(cond, mutex, timeout); } -/** - * \ingroup simix_synchro_management - * - */ -void simcall_cond_broadcast(smx_cond_t cond) -{ - simcall_BODY_cond_broadcast(cond); -} - /** * \ingroup simix_synchro_management * diff --git a/src/simix/popping_accessors.hpp b/src/simix/popping_accessors.hpp index 5be2202c1b..cdb11ef555 100644 --- a/src/simix/popping_accessors.hpp +++ b/src/simix/popping_accessors.hpp @@ -1096,19 +1096,6 @@ static inline void simcall_cond_init__set__result(smx_simcall_t simcall, smx_con simgrid::simix::marshal(simcall->result, result); } -static inline smx_cond_t simcall_cond_signal__get__cond(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal(simcall->args[0]); -} -static inline smx_cond_t simcall_cond_signal__getraw__cond(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal_raw(simcall->args[0]); -} -static inline void simcall_cond_signal__set__cond(smx_simcall_t simcall, smx_cond_t arg) -{ - simgrid::simix::marshal(simcall->args[0], arg); -} - static inline smx_cond_t simcall_cond_wait__get__cond(smx_simcall_t simcall) { return simgrid::simix::unmarshal(simcall->args[0]); @@ -1171,19 +1158,6 @@ static inline void simcall_cond_wait_timeout__set__timeout(smx_simcall_t simcall simgrid::simix::marshal(simcall->args[2], arg); } -static inline smx_cond_t simcall_cond_broadcast__get__cond(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal(simcall->args[0]); -} -static inline smx_cond_t simcall_cond_broadcast__getraw__cond(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal_raw(simcall->args[0]); -} -static inline void simcall_cond_broadcast__set__cond(smx_simcall_t simcall, smx_cond_t arg) -{ - simgrid::simix::marshal(simcall->args[0], arg); -} - static inline smx_sem_t simcall_sem_acquire__get__sem(smx_simcall_t simcall) { return simgrid::simix::unmarshal(simcall->args[0]); @@ -1406,10 +1380,8 @@ XBT_PRIVATE void simcall_HANDLER_comm_testany(smx_simcall_t simcall, boost::intr 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_mutex_unlock(smx_simcall_t simcall, smx_mutex_t mutex); -XBT_PRIVATE void simcall_HANDLER_cond_signal(smx_simcall_t simcall, smx_cond_t cond); XBT_PRIVATE void simcall_HANDLER_cond_wait(smx_simcall_t simcall, smx_cond_t cond, smx_mutex_t mutex); XBT_PRIVATE void simcall_HANDLER_cond_wait_timeout(smx_simcall_t simcall, smx_cond_t cond, smx_mutex_t mutex, double timeout); -XBT_PRIVATE void simcall_HANDLER_cond_broadcast(smx_simcall_t simcall, smx_cond_t cond); XBT_PRIVATE void simcall_HANDLER_sem_acquire(smx_simcall_t simcall, smx_sem_t sem); XBT_PRIVATE void simcall_HANDLER_sem_acquire_timeout(smx_simcall_t simcall, smx_sem_t sem, double timeout); XBT_PRIVATE void simcall_HANDLER_storage_read(smx_simcall_t simcall, surf_storage_t st, sg_size_t size); diff --git a/src/simix/popping_bodies.cpp b/src/simix/popping_bodies.cpp index 9914be1bc2..7753890c81 100644 --- a/src/simix/popping_bodies.cpp +++ b/src/simix/popping_bodies.cpp @@ -200,13 +200,6 @@ inline static smx_cond_t simcall_BODY_cond_init() return simcall(SIMCALL_COND_INIT); } -inline static void simcall_BODY_cond_signal(smx_cond_t cond) -{ - if (0) /* Go to that function to follow the code flow through the simcall barrier */ - simcall_HANDLER_cond_signal(&SIMIX_process_self()->simcall, cond); - return simcall(SIMCALL_COND_SIGNAL, cond); -} - inline static void simcall_BODY_cond_wait(smx_cond_t cond, smx_mutex_t mutex) { if (0) /* Go to that function to follow the code flow through the simcall barrier */ @@ -221,13 +214,6 @@ inline static void simcall_BODY_cond_wait_timeout(smx_cond_t cond, smx_mutex_t m return simcall(SIMCALL_COND_WAIT_TIMEOUT, cond, mutex, timeout); } -inline static void simcall_BODY_cond_broadcast(smx_cond_t cond) -{ - if (0) /* Go to that function to follow the code flow through the simcall barrier */ - simcall_HANDLER_cond_broadcast(&SIMIX_process_self()->simcall, cond); - return simcall(SIMCALL_COND_BROADCAST, cond); -} - inline static void simcall_BODY_sem_acquire(smx_sem_t sem) { if (0) /* Go to that function to follow the code flow through the simcall barrier */ diff --git a/src/simix/popping_enum.h b/src/simix/popping_enum.h index 1d0791bb3b..624fcc1693 100644 --- a/src/simix/popping_enum.h +++ b/src/simix/popping_enum.h @@ -42,10 +42,8 @@ typedef enum { SIMCALL_MUTEX_TRYLOCK, SIMCALL_MUTEX_UNLOCK, SIMCALL_COND_INIT, - SIMCALL_COND_SIGNAL, SIMCALL_COND_WAIT, SIMCALL_COND_WAIT_TIMEOUT, - SIMCALL_COND_BROADCAST, SIMCALL_SEM_ACQUIRE, SIMCALL_SEM_ACQUIRE_TIMEOUT, SIMCALL_STORAGE_READ, diff --git a/src/simix/popping_generated.cpp b/src/simix/popping_generated.cpp index b9b4caabff..f70946c9ae 100644 --- a/src/simix/popping_generated.cpp +++ b/src/simix/popping_generated.cpp @@ -51,10 +51,8 @@ const char* simcall_names[] = { "SIMCALL_MUTEX_TRYLOCK", "SIMCALL_MUTEX_UNLOCK", "SIMCALL_COND_INIT", - "SIMCALL_COND_SIGNAL", "SIMCALL_COND_WAIT", "SIMCALL_COND_WAIT_TIMEOUT", - "SIMCALL_COND_BROADCAST", "SIMCALL_SEM_ACQUIRE", "SIMCALL_SEM_ACQUIRE_TIMEOUT", "SIMCALL_STORAGE_READ", @@ -186,11 +184,6 @@ case SIMCALL_COND_INIT: SIMIX_simcall_answer(simcall); break; -case SIMCALL_COND_SIGNAL: - simcall_HANDLER_cond_signal(simcall, simgrid::simix::unmarshal(simcall->args[0])); - SIMIX_simcall_answer(simcall); - break; - case SIMCALL_COND_WAIT: simcall_HANDLER_cond_wait(simcall, simgrid::simix::unmarshal(simcall->args[0]), simgrid::simix::unmarshal(simcall->args[1])); break; @@ -199,11 +192,6 @@ case SIMCALL_COND_WAIT_TIMEOUT: simcall_HANDLER_cond_wait_timeout(simcall, simgrid::simix::unmarshal(simcall->args[0]), simgrid::simix::unmarshal(simcall->args[1]), simgrid::simix::unmarshal(simcall->args[2])); break; -case SIMCALL_COND_BROADCAST: - simcall_HANDLER_cond_broadcast(simcall, simgrid::simix::unmarshal(simcall->args[0])); - SIMIX_simcall_answer(simcall); - break; - case SIMCALL_SEM_ACQUIRE: simcall_HANDLER_sem_acquire(simcall, simgrid::simix::unmarshal(simcall->args[0])); break; diff --git a/src/simix/simcalls.in b/src/simix/simcalls.in index 5f695cd0ff..49f36d7253 100644 --- a/src/simix/simcalls.in +++ b/src/simix/simcalls.in @@ -63,10 +63,8 @@ int mutex_trylock(smx_mutex_t mutex); void mutex_unlock(smx_mutex_t mutex); smx_cond_t cond_init() [[nohandler]]; -void cond_signal(smx_cond_t cond); void cond_wait(smx_cond_t cond, smx_mutex_t mutex) [[block]]; void cond_wait_timeout(smx_cond_t cond, smx_mutex_t mutex, double timeout) [[block]]; -void cond_broadcast(smx_cond_t cond); void sem_acquire(smx_sem_t sem) [[block]]; void sem_acquire_timeout(smx_sem_t sem, double timeout) [[block]]; diff --git a/src/xbt/xbt_os_synchro.cpp b/src/xbt/xbt_os_synchro.cpp index 79b0b19d8e..b78dfdd2ac 100644 --- a/src/xbt/xbt_os_synchro.cpp +++ b/src/xbt/xbt_os_synchro.cpp @@ -66,12 +66,14 @@ int xbt_cond_timedwait(xbt_cond_t cond, xbt_mutex_t mutex, double delay) void xbt_cond_signal(xbt_cond_t cond) { - simcall_cond_signal((smx_cond_t)cond); + // FIXME: this should use s4u + simgrid::simix::kernelImmediate([cond]() { cond->signal(); }); } void xbt_cond_broadcast(xbt_cond_t cond) { - simcall_cond_broadcast((smx_cond_t)cond); + // FIXME: this should use s4u + simgrid::simix::kernelImmediate([cond]() { cond->broadcast(); }); } void xbt_cond_destroy(xbt_cond_t cond)