4 int pthread_barrier_wait(barrier_t *barrier);
12 - current barrier count, # of threads still needed.
14 unsigned int init_count;
15 - number of threads needed for the barrier to continue.
17 unsigned int curr_event;
21 pthread_barrier_wait(barrier_t *barrier)
26 lll_lock(barrier->lock);
27 if (!--barrier->left) {
28 barrier->curr_event++;
29 futex_wake(&barrier->curr_event, INT_MAX)
31 result = BARRIER_SERIAL_THREAD;
33 event = barrier->curr_event;
34 lll_unlock(barrier->lock);
36 futex_wait(&barrier->curr_event, event)
37 } while (event == barrier->curr_event);
40 if (atomic_increment_val (barrier->left) == barrier->init_count)
41 lll_unlock(barrier->lock);