Lines Matching refs:sema
403 pipe_semaphore_init(pipe_semaphore *sema, int init_val) in pipe_semaphore_init() argument
405 pipe_mutex_init(sema->mutex); in pipe_semaphore_init()
406 pipe_condvar_init(sema->cond); in pipe_semaphore_init()
407 sema->counter = init_val; in pipe_semaphore_init()
411 pipe_semaphore_destroy(pipe_semaphore *sema) in pipe_semaphore_destroy() argument
413 pipe_mutex_destroy(sema->mutex); in pipe_semaphore_destroy()
414 pipe_condvar_destroy(sema->cond); in pipe_semaphore_destroy()
419 pipe_semaphore_signal(pipe_semaphore *sema) in pipe_semaphore_signal() argument
421 pipe_mutex_lock(sema->mutex); in pipe_semaphore_signal()
422 sema->counter++; in pipe_semaphore_signal()
423 pipe_condvar_signal(sema->cond); in pipe_semaphore_signal()
424 pipe_mutex_unlock(sema->mutex); in pipe_semaphore_signal()
429 pipe_semaphore_wait(pipe_semaphore *sema) in pipe_semaphore_wait() argument
431 pipe_mutex_lock(sema->mutex); in pipe_semaphore_wait()
432 while (sema->counter <= 0) { in pipe_semaphore_wait()
433 pipe_condvar_wait(sema->cond, sema->mutex); in pipe_semaphore_wait()
435 sema->counter--; in pipe_semaphore_wait()
436 pipe_mutex_unlock(sema->mutex); in pipe_semaphore_wait()