[Go to CFHT Home Page] Man Pages
Back to Software Index  BORDER=0Manpage Top Level
    sem_getvalue(3R) manual page Table of Contents

Name

sem_getvalue - get the value of a semaphore

Synopsis

cc [ flag ... ] file ... -lposix4 [ library ... ]

#include <semaphore.h>

int sem_getvalue(sem_t *sem, int *sval);

typedef struct {
...

} sem_t; /*opaque POSIX.4 semaphore*/

MT-Level

MT-Safe

Description

sem_getvalue() updates the location referenced by sval to have the value of the semaphore referenced by sem without affecting the state of the semaphore. The updated value represents an actual semaphore value that occurred at some unspecified time during the call to sem_getvalue(), but may not be the actual value of the semaphore when sem_getvalue() is returned to the caller.

The value set in sval may be zero or positive. If sval is zero, there may be other processes (or LWPs or threads) waiting for the semaphore; if sval is positive, no one is waiting.

Return Values

If successful, sem_getvalue() returns 0, otherwise, it returns -1, and sets errno to indicate the error condition.

Errors

EINVAL
sem does not refer to a valid semaphore.
ENOSYS
sem_getvalue() is not supported by this implementation.

See Also

sem_post(3R) , sem_wait(3R)

Bugs

In Solaris 2.5, these functions always return -1 and set errno to ENOSYS, because this release does not support the Semaphores option. It is our intention to provide support for these interfaces in future releases.


Table of Contents