Lines Matching defs:bar
44 pthread_barrier_t bar;
51 bar = *barrier;
52 THR_UMUTEX_LOCK(curthread, &bar->b_lock);
53 if (bar->b_destroying) {
54 THR_UMUTEX_UNLOCK(curthread, &bar->b_lock);
57 bar->b_destroying = 1;
59 if (bar->b_waiters > 0) {
60 bar->b_destroying = 0;
61 THR_UMUTEX_UNLOCK(curthread, &bar->b_lock);
64 if (bar->b_refcount != 0) {
65 _thr_ucond_wait(&bar->b_cv, &bar->b_lock, NULL, 0);
66 THR_UMUTEX_LOCK(curthread, &bar->b_lock);
70 bar->b_destroying = 0;
71 THR_UMUTEX_UNLOCK(curthread, &bar->b_lock);
74 free(bar);
82 pthread_barrier_t bar;
89 bar = malloc(sizeof(struct pthread_barrier));
90 if (bar == NULL)
93 _thr_umutex_init(&bar->b_lock);
94 _thr_ucond_init(&bar->b_cv);
95 bar->b_cycle = 0;
96 bar->b_waiters = 0;
97 bar->b_count = count;
98 bar->b_refcount = 0;
99 *barrier = bar;
108 pthread_barrier_t bar;
115 bar = *barrier;
116 THR_UMUTEX_LOCK(curthread, &bar->b_lock);
117 if (++bar->b_waiters == bar->b_count) {
119 bar->b_waiters = 0;
120 bar->b_cycle++;
121 _thr_ucond_broadcast(&bar->b_cv);
122 THR_UMUTEX_UNLOCK(curthread, &bar->b_lock);
125 cycle = bar->b_cycle;
126 bar->b_refcount++;
128 _thr_ucond_wait(&bar->b_cv, &bar->b_lock, NULL, 0);
129 THR_UMUTEX_LOCK(curthread, &bar->b_lock);
131 } while (cycle == bar->b_cycle);
132 if (--bar->b_refcount == 0 && bar->b_destroying)
133 _thr_ucond_broadcast(&bar->b_cv);
134 THR_UMUTEX_UNLOCK(curthread, &bar->b_lock);