add pthread_cond_broadcast
authorweiyu <weiyuluo1232@gmail.com>
Fri, 19 Jul 2019 18:17:58 +0000 (11:17 -0700)
committerweiyu <weiyuluo1232@gmail.com>
Fri, 19 Jul 2019 18:17:58 +0000 (11:17 -0700)
include/mypthread.h
pthread.cc

index cffd8c2d1cb93b90ff43f8e56890af13167336e0..20cddb9cf64da03d7c5742c05bf5a5e0b0734aaa 100644 (file)
@@ -44,7 +44,6 @@ int pthread_attr_setscope(pthread_attr_t *, int);
 int pthread_attr_setstackaddr(pthread_attr_t *, void *);
 int pthread_attr_setstacksize(pthread_attr_t *, size_t);
 int pthread_cancel(pthread_t);
-int pthread_cond_broadcast(pthread_cond_t *);
 int pthread_cond_destroy(pthread_cond_t *);
 int pthread_condattr_destroy(pthread_condattr_t *);
 int pthread_condattr_getpshared(const pthread_condattr_t *, int *);
index 276e37587e43de82e2ff8f84ca30aca3dc4cb7d9..95fa57a24515aaa69587eb08ea87d1a6a6849d09 100644 (file)
@@ -202,3 +202,15 @@ int pthread_cond_signal(pthread_cond_t *p_cond) {
        v->notify_one();
        return 0;
 }
+
+int pthread_cond_broadcast(pthread_cond_t *p_cond) {
+       // notify all blocked threads
+       ModelExecution *execution = model->get_execution();
+       if ( !execution->getCondMap()->contains(p_cond) )
+               pthread_cond_init(p_cond, NULL);
+
+       cdsc::snapcondition_variable *v = execution->getCondMap()->get(p_cond);
+
+       v->notify_all();
+       return 0;
+}