cpsema(D3X)

cpsema - conditionally perform a "P" or wait semaphore operation

As shipped in IRIX 6.5.15. Unchanged since IRIX 6.5.

NAME
     cpsema - conditionally perform a "P" or wait semaphore operation

SYNOPSIS
     #include "sys/types.h"
     #include "sys/sema.h"

     cpsema(sema_t *semap);

   Arguments
     semap
          Expects a pointer to the semaphore you want cpsema to conditionally
          decrement.

DESCRIPTION
     cpsema conditionally performs a "P" operation depending on the current
     value of the semaphore. If the semaphore value is less than or equal to
     0, cpsema returns without altering the semaphore. Otherwise, cpsema
     decrements the semaphore value by 1 and returns. cpsema effectively
     performs a "P" operation if it does not cause the process to sleep;
     otherwise, it simply returns. To initialize semaphores before using them,
     call initnsema(D3X) or initnsema_mutex(D3X).

   Return Values
     cpsema returns 0 if the semaphore value is less than or equal to 0. (If
     cpsema returns 0, psema(D3X) would have slept.) Otherwise cpsema returns
     1.

   See Also
     initnsema(D3X), initnsema_mutex(D3X), psema(D3X), SLEEP_TRYLOCK(D3)