1sem_getvalue(3C) Standard C Library Functions sem_getvalue(3C)
2
3
4
6 sem_getvalue - get the value of a semaphore
7
9 #include <semaphore.h>
10
11 int sem_getvalue(sem_t *restrict sem, int *restrict sval);
12
13
15 The sem_getvalue() function updates the location referenced by the sval
16 argument to have the value of the semaphore referenced by sem without
17 affecting the state of the semaphore. The updated value represents an
18 actual semaphore value that occurred at some unspecified time during
19 the call, but it need not be the actual value of the semaphore when it
20 is returned to the calling process.
21
22
23 If sem is locked, then the value returned by sem_getvalue() is either
24 zero or a negative number whose absolute value represents the number of
25 processes waiting for the semaphore at some unspecified time during the
26 call.
27
28
29 The value set in sval may be 0 or positive. If sval is 0, there may be
30 other processes (or LWPs or threads) waiting for the semaphore; if sval
31 is positive, no process is waiting.
32
34 Upon successful completion, sem_getvalue() returns 0. Otherwise, it
35 returns −1 and sets errno to indicate the error.
36
38 The sem_getvalue() function will fail if:
39
40 EINVAL The sem argument does not refer to a valid semaphore.
41
42
43 ENOSYS The sem_getvalue() function is not supported by the system.
44
45
47 See attributes(5) for descriptions of the following attributes:
48
49
50
51
52 ┌─────────────────────────────┬─────────────────────────────┐
53 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
54 ├─────────────────────────────┼─────────────────────────────┤
55 │Interface Stability │Committed │
56 ├─────────────────────────────┼─────────────────────────────┤
57 │MT-Level │MT-Safe │
58 ├─────────────────────────────┼─────────────────────────────┤
59 │Standard │See standards(5). │
60 └─────────────────────────────┴─────────────────────────────┘
61
63 semctl(2), semget(2), semop(2), sem_post(3C), sem_wait(3C),
64 attributes(5), standards(5)
65
66
67
68SunOS 5.11 5 Feb 2008 sem_getvalue(3C)