Lines Matching +full:phase +full:- +full:locked
27 * Reusable 2 PHASE task barrier (rendez-vous point) implementation for N tasks.
28 * Based on the Little book of semaphores - https://greenteapress.com/wp/semaphores/
57 tb->n = 0; in task_barrier_init()
58 atomic_set(&tb->count, 0); in task_barrier_init()
59 sema_init(&tb->enter_turnstile, 0); in task_barrier_init()
60 sema_init(&tb->exit_turnstile, 0); in task_barrier_init()
65 tb->n++; in task_barrier_add_task()
70 tb->n--; in task_barrier_rem_task()
76 * When all thread passed this code the entry barrier is back to locked state.
80 if (atomic_inc_return(&tb->count) == tb->n) in task_barrier_enter()
81 task_barrier_signal_turnstile(&tb->enter_turnstile, tb->n); in task_barrier_enter()
83 down(&tb->enter_turnstile); in task_barrier_enter()
94 if (atomic_dec_return(&tb->count) == 0) in task_barrier_exit()
95 task_barrier_signal_turnstile(&tb->exit_turnstile, tb->n); in task_barrier_exit()
97 down(&tb->exit_turnstile); in task_barrier_exit()