| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | .\" $NetBSD: sem_wait.3,v 1.2 2012/03/08 21:59:29 joerg Exp $ | | 1 | .\" $NetBSD: sem_wait.3,v 1.3 2012/03/08 22:13:32 wiz Exp $ |
2 | .\" | | 2 | .\" |
3 | .\" Copyright (C) 2000 Jason Evans <jasone@FreeBSD.org>. | | 3 | .\" Copyright (C) 2000 Jason Evans <jasone@FreeBSD.org>. |
4 | .\" All rights reserved. | | 4 | .\" All rights reserved. |
5 | .\" | | 5 | .\" |
6 | .\" Redistribution and use in source and binary forms, with or without | | 6 | .\" Redistribution and use in source and binary forms, with or without |
7 | .\" modification, are permitted provided that the following conditions | | 7 | .\" modification, are permitted provided that the following conditions |
8 | .\" are met: | | 8 | .\" are met: |
9 | .\" 1. Redistributions of source code must retain the above copyright | | 9 | .\" 1. Redistributions of source code must retain the above copyright |
10 | .\" notice(s), this list of conditions and the following disclaimer as | | 10 | .\" notice(s), this list of conditions and the following disclaimer as |
11 | .\" the first lines of this file unmodified other than the possible | | 11 | .\" the first lines of this file unmodified other than the possible |
12 | .\" addition of one or more copyright notices. | | 12 | .\" addition of one or more copyright notices. |
13 | .\" 2. Redistributions in binary form must reproduce the above copyright | | 13 | .\" 2. Redistributions in binary form must reproduce the above copyright |
14 | .\" notice(s), this list of conditions and the following disclaimer in | | 14 | .\" notice(s), this list of conditions and the following disclaimer in |
| @@ -22,36 +22,37 @@ | | | @@ -22,36 +22,37 @@ |
22 | .\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 22 | .\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
23 | .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 23 | .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
24 | .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | | 24 | .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
25 | .\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | | 25 | .\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
26 | .\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE | | 26 | .\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
27 | .\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, | | 27 | .\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
28 | .\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 28 | .\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 | .\" | | 29 | .\" |
30 | .Dd February 29, 2012 | | 30 | .Dd February 29, 2012 |
31 | .Dt SEM_WAIT 3 | | 31 | .Dt SEM_WAIT 3 |
32 | .Os | | 32 | .Os |
33 | .Sh NAME | | 33 | .Sh NAME |
34 | .Nm sem_wait , | | 34 | .Nm sem_wait , |
| | | 35 | .Nm sem_timedwait , |
35 | .Nm sem_trywait | | 36 | .Nm sem_trywait |
36 | .Nd decrement (lock) a semaphore | | 37 | .Nd decrement (lock) a semaphore |
37 | .Sh LIBRARY | | 38 | .Sh LIBRARY |
38 | .Lb librt | | 39 | .Lb librt |
39 | .Sh SYNOPSIS | | 40 | .Sh SYNOPSIS |
40 | .In semaphore.h | | 41 | .In semaphore.h |
41 | .Ft int | | 42 | .Ft int |
42 | .Fn sem_wait "sem_t *sem" | | 43 | .Fn sem_wait "sem_t *sem" |
43 | .Ft int | | 44 | .Ft int |
44 | .Fn sem_wait "sem_t *sem" "const struct timespec * restrict abstime" | | 45 | .Fn sem_timedwait "sem_t *sem" "const struct timespec * restrict abstime" |
45 | .Ft int | | 46 | .Ft int |
46 | .Fn sem_trywait "sem_t *sem" | | 47 | .Fn sem_trywait "sem_t *sem" |
47 | .Sh DESCRIPTION | | 48 | .Sh DESCRIPTION |
48 | The | | 49 | The |
49 | .Fn sem_wait | | 50 | .Fn sem_wait |
50 | function decrements (locks) the semaphore pointed to by | | 51 | function decrements (locks) the semaphore pointed to by |
51 | .Fa sem , | | 52 | .Fa sem , |
52 | but blocks if the value of | | 53 | but blocks if the value of |
53 | .Fa sem | | 54 | .Fa sem |
54 | is zero, until the value is non-zero and the value can be decremented. | | 55 | is zero, until the value is non-zero and the value can be decremented. |
55 | .Pp | | 56 | .Pp |
56 | The | | 57 | The |
57 | .Fn sem_timedwait | | 58 | .Fn sem_timedwait |
| @@ -61,27 +62,27 @@ for the value of | | | @@ -61,27 +62,27 @@ for the value of |
61 | .Fa sem | | 62 | .Fa sem |
62 | to be non-zero. | | 63 | to be non-zero. |
63 | .Pp | | 64 | .Pp |
64 | The | | 65 | The |
65 | .Fn sem_trywait | | 66 | .Fn sem_trywait |
66 | function decrements (locks) the semaphore pointed to by | | 67 | function decrements (locks) the semaphore pointed to by |
67 | .Fa sem | | 68 | .Fa sem |
68 | only if the value is non-zero. | | 69 | only if the value is non-zero. |
69 | Otherwise, the semaphore is not decremented and an error is returned. | | 70 | Otherwise, the semaphore is not decremented and an error is returned. |
70 | .Sh RETURN VALUES | | 71 | .Sh RETURN VALUES |
71 | .Rv -std sem_wait | | 72 | .Rv -std sem_wait |
72 | .Sh ERRORS | | 73 | .Sh ERRORS |
73 | .Fn sem_wait , | | 74 | .Fn sem_wait , |
74 | .Fn sem_timedwait | | 75 | .Fn sem_timedwait , |
75 | and | | 76 | and |
76 | .Fn sem_trywait | | 77 | .Fn sem_trywait |
77 | will fail if: | | 78 | will fail if: |
78 | .Bl -tag -width Er | | 79 | .Bl -tag -width Er |
79 | .It Bq Er EINVAL | | 80 | .It Bq Er EINVAL |
80 | .Fa sem | | 81 | .Fa sem |
81 | points to an invalid semaphore. | | 82 | points to an invalid semaphore. |
82 | .El | | 83 | .El |
83 | .Pp | | 84 | .Pp |
84 | Additionally, | | 85 | Additionally, |
85 | .Fn sem_trywait | | 86 | .Fn sem_trywait |
86 | will fail if: | | 87 | will fail if: |
87 | .Bl -tag -width Er | | 88 | .Bl -tag -width Er |