diff options
| author | David Xu <davidxu@FreeBSD.org> | 2006-12-05 06:54:25 +0000 |
|---|---|---|
| committer | David Xu <davidxu@FreeBSD.org> | 2006-12-05 06:54:25 +0000 |
| commit | 4d617f2d108bf7dd4fd7097d265efb0733897c4d (patch) | |
| tree | 6699e8d2c0b214b4ce0461d7a05f5a95a1ae3d7a /lib/libthr/thread/thr_barrier.c | |
| parent | 670b44d65af20c02916f5fe616902f931d6a3694 (diff) | |
Notes
Diffstat (limited to 'lib/libthr/thread/thr_barrier.c')
| -rw-r--r-- | lib/libthr/thread/thr_barrier.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/libthr/thread/thr_barrier.c b/lib/libthr/thread/thr_barrier.c index 48fb7ddca7c31..cafba69dbc25e 100644 --- a/lib/libthr/thread/thr_barrier.c +++ b/lib/libthr/thread/thr_barrier.c @@ -70,6 +70,7 @@ _pthread_barrier_init(pthread_barrier_t *barrier, return (ENOMEM); _thr_umutex_init(&bar->b_lock); + _thr_ucond_init(&bar->b_cv); bar->b_cycle = 0; bar->b_waiters = 0; bar->b_count = count; @@ -83,7 +84,7 @@ _pthread_barrier_wait(pthread_barrier_t *barrier) { struct pthread *curthread = _get_curthread(); pthread_barrier_t bar; - long cycle; + int64_t cycle; int ret; if (barrier == NULL || *barrier == NULL) @@ -95,16 +96,16 @@ _pthread_barrier_wait(pthread_barrier_t *barrier) /* Current thread is lastest thread */ bar->b_waiters = 0; bar->b_cycle++; - _thr_umtx_wake(&bar->b_cycle, bar->b_count - 1); + _thr_ucond_broadcast(&bar->b_cv); THR_UMUTEX_UNLOCK(curthread, &bar->b_lock); ret = PTHREAD_BARRIER_SERIAL_THREAD; } else { cycle = bar->b_cycle; - THR_UMUTEX_UNLOCK(curthread, &bar->b_lock); do { - _thr_umtx_wait(&bar->b_cycle, cycle, NULL); + _thr_ucond_wait(&bar->b_cv, &bar->b_lock, NULL, 0); /* test cycle to avoid bogus wakeup */ } while (cycle == bar->b_cycle); + THR_UMUTEX_UNLOCK(curthread, &bar->b_lock); ret = 0; } return (ret); |
