Lines Matching refs:sema
78 pipe_semaphore_init(pipe_semaphore *sema, int init_val) in pipe_semaphore_init() argument
80 (void) mtx_init(&sema->mutex, mtx_plain); in pipe_semaphore_init()
81 cnd_init(&sema->cond); in pipe_semaphore_init()
82 sema->counter = init_val; in pipe_semaphore_init()
86 pipe_semaphore_destroy(pipe_semaphore *sema) in pipe_semaphore_destroy() argument
88 mtx_destroy(&sema->mutex); in pipe_semaphore_destroy()
89 cnd_destroy(&sema->cond); in pipe_semaphore_destroy()
94 pipe_semaphore_signal(pipe_semaphore *sema) in pipe_semaphore_signal() argument
96 mtx_lock(&sema->mutex); in pipe_semaphore_signal()
97 sema->counter++; in pipe_semaphore_signal()
98 cnd_signal(&sema->cond); in pipe_semaphore_signal()
99 mtx_unlock(&sema->mutex); in pipe_semaphore_signal()
104 pipe_semaphore_wait(pipe_semaphore *sema) in pipe_semaphore_wait() argument
106 mtx_lock(&sema->mutex); in pipe_semaphore_wait()
107 while (sema->counter <= 0) { in pipe_semaphore_wait()
108 cnd_wait(&sema->cond, &sema->mutex); in pipe_semaphore_wait()
110 sema->counter--; in pipe_semaphore_wait()
111 mtx_unlock(&sema->mutex); in pipe_semaphore_wait()