1SEM_GETVALUE(3)            Linux Programmer's Manual           SEM_GETVALUE(3)
2
3
4

NAME

6       sem_getvalue - get the value of a semaphore
7

SYNOPSIS

9       #include <semaphore.h>
10
11       int sem_getvalue(sem_t *sem, int *sval);
12

DESCRIPTION

14       sem_getvalue() places the current value of the semaphore pointed to sem
15       into the integer pointed to by sval.
16
17       If one or more processes or threads are blocked  waiting  to  lock  the
18       semaphore  with sem_wait(3), POSIX.1-2001 permits two possibilities for
19       the value returned in sval: either 0 is returned; or a negative  number
20       whose  absolute  value  is  the  count  of  the number of processes and
21       threads currently blocked in sem_wait(3).  Linux adopts the former  be‐
22       haviour.
23

RETURN VALUE

25       sem_getvalue() returns 0 on success; on error, -1 is returned and errno
26       is set to indicate the error.
27

ERRORS

29       EINVAL sem is not a valid semaphore.
30

NOTES

32       The value of the  semaphore  may  already  have  changed  by  the  time
33       sem_getvalue() returns.
34

CONFORMING TO

36       POSIX.1-2001.
37

SEE ALSO

39       sem_post(3), sem_wait(3), sem_overview(7)
40
41
42
43Linux 2.6.16                      2006-03-25                   SEM_GETVALUE(3)
Impressum