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
13       Link with -pthread.
14

DESCRIPTION

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

RETURN VALUE

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

ERRORS

31       EINVAL sem is not a valid semaphore.
32

ATTRIBUTES

34       For  an  explanation  of  the  terms  used   in   this   section,   see
35       attributes(7).
36
37       ┌───────────────┬───────────────┬─────────┐
38Interface      Attribute     Value   
39       ├───────────────┼───────────────┼─────────┤
40sem_getvalue() │ Thread safety │ MT-Safe │
41       └───────────────┴───────────────┴─────────┘

CONFORMING TO

43       POSIX.1-2001, POSIX.1-2008.
44

NOTES

46       The  value  of  the  semaphore  may  already  have  changed by the time
47       sem_getvalue() returns.
48

SEE ALSO

50       sem_post(3), sem_wait(3), sem_overview(7)
51

COLOPHON

53       This page is part of release 4.16 of the Linux  man-pages  project.   A
54       description  of  the project, information about reporting bugs, and the
55       latest    version    of    this    page,    can     be     found     at
56       https://www.kernel.org/doc/man-pages/.
57
58
59
60Linux                             2017-09-15                   SEM_GETVALUE(3)
Impressum