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  be‐
24       havior.
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.  (The  glibc  implementation  cur‐
32              rently does not check whether sem is valid.)
33

ATTRIBUTES

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

CONFORMING TO

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

NOTES

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

SEE ALSO

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

COLOPHON

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