Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Template implem of cond_timedwait in sthread
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 12 Nov 2023 20:49:02 +0000 (21:49 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Mon, 13 Nov 2023 15:05:52 +0000 (16:05 +0100)
src/sthread/sthread.c
src/sthread/sthread.h
src/sthread/sthread_impl.cpp

index 0bf6c54..af26022 100644 (file)
@@ -42,6 +42,7 @@ static int (*raw_pthread_cond_init)(pthread_cond_t*, const pthread_condattr_t*);
 static int (*raw_pthread_cond_signal)(pthread_cond_t*);
 static int (*raw_pthread_cond_broadcast)(pthread_cond_t*);
 static int (*raw_pthread_cond_wait)(pthread_cond_t*, pthread_mutex_t*);
+static int (*raw_pthread_cond_timedwait)(pthread_cond_t*, pthread_mutex_t*, const struct timespec* abstime);
 static int (*raw_pthread_cond_destroy)(pthread_cond_t*);
 
 static unsigned int (*raw_sleep)(unsigned int);
@@ -80,6 +81,7 @@ static void intercepter_init()
   raw_pthread_cond_signal    = dlsym(RTLD_NEXT, "raw_pthread_cond_signal");
   raw_pthread_cond_broadcast = dlsym(RTLD_NEXT, "raw_pthread_cond_broadcast");
   raw_pthread_cond_wait      = dlsym(RTLD_NEXT, "raw_pthread_cond_wait");
+  raw_pthread_cond_timedwait = dlsym(RTLD_NEXT, "raw_pthread_cond_timedwait");
   raw_pthread_cond_destroy   = dlsym(RTLD_NEXT, "raw_pthread_cond_destroy");
 
   raw_sleep        = dlsym(RTLD_NEXT, "sleep");
@@ -152,6 +154,8 @@ intercepted_pthcall(cond_signal, (pthread_cond_t * cond), (cond), ((sthread_cond
 intercepted_pthcall(cond_broadcast, (pthread_cond_t * cond), (cond), ((sthread_cond_t*)cond));
 intercepted_pthcall(cond_wait, (pthread_cond_t * cond, pthread_mutex_t* mutex), (cond, mutex),
                     ((sthread_cond_t*)cond, (sthread_mutex_t*)mutex));
+intercepted_pthcall(cond_timedwait, (pthread_cond_t * cond, pthread_mutex_t* mutex, const struct timespec* abstime),
+                    (cond, mutex, abstime), ((sthread_cond_t*)cond, (sthread_mutex_t*)mutex, abstime));
 intercepted_pthcall(cond_destroy, (pthread_cond_t * cond), (cond), ((sthread_cond_t*)cond));
 
 #define intercepted_call(rettype, name, raw_params, call_params, sim_params)                                           \
index 8447d97..ecc6494 100644 (file)
@@ -74,6 +74,7 @@ int sthread_cond_init(sthread_cond_t* cond, sthread_condattr_t* attr);
 int sthread_cond_signal(sthread_cond_t* cond);
 int sthread_cond_broadcast(sthread_cond_t* cond);
 int sthread_cond_wait(sthread_cond_t* cond, sthread_mutex_t* mutex);
+int sthread_cond_timedwait(sthread_cond_t* cond, sthread_mutex_t* mutex, const struct timespec* abs_timeout);
 int sthread_cond_destroy(sthread_cond_t* cond);
 
 typedef struct {
index 063d265..08c7da5 100644 (file)
@@ -265,6 +265,10 @@ int sthread_cond_wait(sthread_cond_t* cond, sthread_mutex_t* mutex)
   static_cast<sg4::ConditionVariable*>(cond->cond)->wait(static_cast<sg4::Mutex*>(mutex->mutex));
   return 0;
 }
+int sthread_cond_timedwait(sthread_cond_t* cond, sthread_mutex_t* mutex, const struct timespec* abs_timeout)
+{
+  THROW_UNIMPLEMENTED;
+}
 int sthread_cond_destroy(sthread_cond_t* cond)
 {
   XBT_DEBUG("%s(%p)", __func__, cond);
@@ -339,30 +343,3 @@ int sthread_usleep(double seconds)
   simgrid::s4u::this_actor::sleep_for(seconds);
   return 0;
 }
-
-#if 0
-int pthread_cond_init(pthread_cond_t *cond, pthread_condattr_t *cond_attr) {
-    *cond = sg_cond_init();
-    return 0;
-}
-
-int pthread_cond_signal(pthread_cond_t *cond) {
-       sg_cond_notify_one(*cond);
-    return 0;
-}
-
-int pthread_cond_broadcast(pthread_cond_t *cond) {
-       sg_cond_notify_all(*cond);
-    return 0;
-}
-
-int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) {
-       sg_cond_wait(*cond, *mutex);
-    return 0;
-}
-
-int pthread_cond_destroy(pthread_cond_t *cond) {
-       sg_cond_destroy(*cond);
-    return 0;
-}
-#endif