1SEM_GETVALUE(3P) POSIX Programmer's Manual SEM_GETVALUE(3P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
11
13 sem_getvalue — get the value of a semaphore
14
16 #include <semaphore.h>
17
18 int sem_getvalue(sem_t *restrict sem, int *restrict sval);
19
21 The sem_getvalue() function shall update the location referenced by the
22 sval argument to have the value of the semaphore referenced by sem
23 without affecting the state of the semaphore. The updated value repre‐
24 sents an actual semaphore value that occurred at some unspecified time
25 during the call, but it need not be the actual value of the semaphore
26 when it is returned to the calling process.
27
28 If sem is locked, then the object to which sval points shall either be
29 set to zero or to a negative number whose absolute value represents the
30 number of processes waiting for the semaphore at some unspecified time
31 during the call.
32
34 Upon successful completion, the sem_getvalue() function shall return a
35 value of zero. Otherwise, it shall return a value of −1 and set errno
36 to indicate the error.
37
39 The sem_getvalue() function may fail if:
40
41 EINVAL The sem argument does not refer to a valid semaphore.
42
43 The following sections are informative.
44
46 None.
47
49 None.
50
52 None.
53
55 None.
56
58 semctl(), semget(), semop(), sem_post(), sem_timedwait(), sem_trywait()
59
60 The Base Definitions volume of POSIX.1‐2008, <semaphore.h>
61
63 Portions of this text are reprinted and reproduced in electronic form
64 from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
65 -- Portable Operating System Interface (POSIX), The Open Group Base
66 Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
67 cal and Electronics Engineers, Inc and The Open Group. (This is
68 POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
69 event of any discrepancy between this version and the original IEEE and
70 The Open Group Standard, the original IEEE and The Open Group Standard
71 is the referee document. The original Standard can be obtained online
72 at http://www.unix.org/online.html .
73
74 Any typographical or formatting errors that appear in this page are
75 most likely to have been introduced during the conversion of the source
76 files to man page format. To report such errors, see https://www.ker‐
77 nel.org/doc/man-pages/reporting_bugs.html .
78
79
80
81IEEE/The Open Group 2013 SEM_GETVALUE(3P)