From: weiyu Date: Fri, 19 Jul 2019 18:17:58 +0000 (-0700) Subject: add pthread_cond_broadcast X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=3037d40e34160064d10f057b94293033c5c58044;p=c11tester.git add pthread_cond_broadcast --- diff --git a/include/mypthread.h b/include/mypthread.h index cffd8c2d..20cddb9c 100644 --- a/include/mypthread.h +++ b/include/mypthread.h @@ -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 *); diff --git a/pthread.cc b/pthread.cc index 276e3758..95fa57a2 100644 --- a/pthread.cc +++ b/pthread.cc @@ -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; +}