Lines Matching defs:bar
47 barrier_init(barrier_t *bar, int nthreads)
49 pthread_mutex_init(&bar->bar_lock, NULL);
50 sema_init(&bar->bar_sem, 0, USYNC_THREAD, NULL);
52 bar->bar_numin = 0;
53 bar->bar_nthr = nthreads;
57 barrier_wait(barrier_t *bar)
59 pthread_mutex_lock(&bar->bar_lock);
61 if (++bar->bar_numin < bar->bar_nthr) {
62 pthread_mutex_unlock(&bar->bar_lock);
63 sema_wait(&bar->bar_sem);
71 bar->bar_numin = 0;
72 for (i = 1; i < bar->bar_nthr; i++)
73 sema_post(&bar->bar_sem);
74 pthread_mutex_unlock(&bar->bar_lock);