sem_getvalue()

get the value of a semaphore 

Realtime Function


SYNOPSIS

#include <semaphore.h>

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


DESCRIPTION

The sem_getvalue() function updates the memory location pointed to by the sval argument to have the value of the semaphore specified by sem. The value used to update the memory location is an actual semaphore value that occurred at some time during the call but, not necessarily, the value of the semaphore when it is returned to the calling process. This function does not change the state of the semaphore.

If the specified semaphore (sem) is locked, sem_getvalue() returns either zero or a positive number whose value represents the number of processes waiting for the semaphore at some unspecified time during the call.


PARAMETERS

sem 

Specifies the semaphore whose value is used to update a memory location.

sval 

Specifies the memory location whose value is to be updated by this function.


RETURN VALUES

When successful, the sem_getvalue() returns zero. Otherwise, it returns -1 and sets errno to one of the following values:

EINVAL 

The sem argument does not refer to a valid semaphore.


EXAMPLES

None.


CONFORMANCE

UNIX 03. Derived from the POSIX Realtime Extension (1003.1b-1993/1003.1i-1995)


MULTITHREAD SAFETY LEVEL

MT-Safe.


PORTING ISSUES

None.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
sem_post(), sem_trywait(), sem_wait(), semctl(), semget(), semop()

Miscellaneous:
semaphores


PTC MKS Toolkit 10.4 Documentation Build 39.