Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
modernize 2 simcalls in ConditionVariable
authorMartin Quinson <martin.quinson@loria.fr>
Mon, 16 Apr 2018 07:50:41 +0000 (09:50 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Mon, 16 Apr 2018 08:39:56 +0000 (10:39 +0200)
include/simgrid/simix.h
src/kernel/activity/ConditionVariableImpl.cpp
src/kernel/activity/ConditionVariableImpl.hpp
src/s4u/s4u_conditionVariable.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
src/xbt/xbt_os_synchro.cpp

index 482973a..d35a3be 100644 (file)
@@ -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);
index b08e892..80aaae6 100644 (file)
@@ -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();
-}
index eeb95d1..a41fa90 100644 (file)
@@ -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
index 0def488..2881d9b 100644 (file)
@@ -79,11 +79,11 @@ std::cv_status ConditionVariable::wait_until(std::unique_lock<Mutex>& 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)
index 943902b..2ecba30 100644 (file)
@@ -494,15 +494,6 @@ smx_cond_t simcall_cond_init()
  * \ingroup simix_synchro_management
  *
  */
-void simcall_cond_signal(smx_cond_t cond)
-{
-  simcall_BODY_cond_signal(cond);
-}
-
-/**
- * \ingroup simix_synchro_management
- *
- */
 void simcall_cond_wait(smx_cond_t cond, smx_mutex_t mutex)
 {
   simcall_BODY_cond_wait(cond, mutex);
@@ -522,15 +513,6 @@ void simcall_cond_wait_timeout(smx_cond_t cond, smx_mutex_t mutex, double timeou
  * \ingroup simix_synchro_management
  *
  */
-void simcall_cond_broadcast(smx_cond_t cond)
-{
-  simcall_BODY_cond_broadcast(cond);
-}
-
-/**
- * \ingroup simix_synchro_management
- *
- */
 void simcall_sem_acquire(smx_sem_t sem)
 {
   simcall_BODY_sem_acquire(sem);
index 5be2202..cdb11ef 100644 (file)
@@ -1096,19 +1096,6 @@ static inline void simcall_cond_init__set__result(smx_simcall_t simcall, smx_con
   simgrid::simix::marshal<smx_cond_t>(simcall->result, result);
 }
 
-static inline smx_cond_t simcall_cond_signal__get__cond(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal<smx_cond_t>(simcall->args[0]);
-}
-static inline smx_cond_t simcall_cond_signal__getraw__cond(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal_raw<smx_cond_t>(simcall->args[0]);
-}
-static inline void simcall_cond_signal__set__cond(smx_simcall_t simcall, smx_cond_t arg)
-{
-  simgrid::simix::marshal<smx_cond_t>(simcall->args[0], arg);
-}
-
 static inline smx_cond_t simcall_cond_wait__get__cond(smx_simcall_t simcall)
 {
   return simgrid::simix::unmarshal<smx_cond_t>(simcall->args[0]);
@@ -1171,19 +1158,6 @@ static inline void simcall_cond_wait_timeout__set__timeout(smx_simcall_t simcall
   simgrid::simix::marshal<double>(simcall->args[2], arg);
 }
 
-static inline smx_cond_t simcall_cond_broadcast__get__cond(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal<smx_cond_t>(simcall->args[0]);
-}
-static inline smx_cond_t simcall_cond_broadcast__getraw__cond(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal_raw<smx_cond_t>(simcall->args[0]);
-}
-static inline void simcall_cond_broadcast__set__cond(smx_simcall_t simcall, smx_cond_t arg)
-{
-  simgrid::simix::marshal<smx_cond_t>(simcall->args[0], arg);
-}
-
 static inline smx_sem_t simcall_sem_acquire__get__sem(smx_simcall_t simcall)
 {
   return simgrid::simix::unmarshal<smx_sem_t>(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);
index 9914be1..7753890 100644 (file)
@@ -200,13 +200,6 @@ inline static smx_cond_t simcall_BODY_cond_init()
   return simcall<smx_cond_t>(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<void, smx_cond_t>(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<void, smx_cond_t, smx_mutex_t, double>(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<void, smx_cond_t>(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 */
index 1d0791b..624fcc1 100644 (file)
@@ -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,
index b9b4caa..f70946c 100644 (file)
@@ -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<smx_cond_t>(simcall->args[0]));
-  SIMIX_simcall_answer(simcall);
-  break;
-
 case SIMCALL_COND_WAIT:
   simcall_HANDLER_cond_wait(simcall, simgrid::simix::unmarshal<smx_cond_t>(simcall->args[0]), simgrid::simix::unmarshal<smx_mutex_t>(simcall->args[1]));
   break;
@@ -199,11 +192,6 @@ case SIMCALL_COND_WAIT_TIMEOUT:
   simcall_HANDLER_cond_wait_timeout(simcall, simgrid::simix::unmarshal<smx_cond_t>(simcall->args[0]), simgrid::simix::unmarshal<smx_mutex_t>(simcall->args[1]), simgrid::simix::unmarshal<double>(simcall->args[2]));
   break;
 
-case SIMCALL_COND_BROADCAST:
-  simcall_HANDLER_cond_broadcast(simcall, simgrid::simix::unmarshal<smx_cond_t>(simcall->args[0]));
-  SIMIX_simcall_answer(simcall);
-  break;
-
 case SIMCALL_SEM_ACQUIRE:
   simcall_HANDLER_sem_acquire(simcall, simgrid::simix::unmarshal<smx_sem_t>(simcall->args[0]));
   break;
index 5f695cd..49f36d7 100644 (file)
@@ -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]];
index 79b0b19..b78dfdd 100644 (file)
@@ -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)