sem_getvalue(PTHREAD)
sem_getvalue --
get the value of a semaphore
Synopsis
cc [options] -Kthread file
#include <semaphore.h>
int sem_getvalue(sem_t *sem, int *sval);
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,
but it need not be the actual value of the semaphore
when it is returned to the calling process.
If
sem
is locked, then the value returned by
sem_getvalue
is either zero or a negative number
whose absolute value represents the number of threads waiting
for the semaphore at some unspecified time during the call.
Return values
sem_getvalue returns a value of zero
on success.
Otherwise, it returns a value of -1 and sets
errno
to indicate the error.
Diagnostics
If the following conditions are detected,
sem_getvalue
returns the corresponding value:
EINVAL-
sem
does not refer to a valid semaphore.
Standards compliance
The Single UNIX Specification, Version 2; The Open Group.
References
sem_post(PTHREAD),
sem_trywait(PTHREAD),
sem_wait(PTHREAD),
semaphore(F)
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 - 01 June 2005