OSDN Git Service

LDP: Update original to LDP v3.68
[linuxjm/LDP_man-pages.git] / original / man3 / sem_post.3
1 '\" t
2 .\" Copyright (C) 2006 Michael Kerrisk <mtk.manpages@gmail.com>
3 .\"
4 .\" %%%LICENSE_START(VERBATIM)
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
8 .\"
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
13 .\"
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein.  The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\" %%%LICENSE_END
25 .\"
26 .TH SEM_POST 3 2014-02-26 "Linux" "Linux Programmer's Manual"
27 .SH NAME
28 sem_post \- unlock a semaphore
29 .SH SYNOPSIS
30 .nf
31 .B #include <semaphore.h>
32 .sp
33 .BI "int sem_post(sem_t *" sem );
34 .fi
35 .sp
36 Link with \fI\-pthread\fP.
37 .SH DESCRIPTION
38 .BR sem_post ()
39 increments (unlocks) the semaphore pointed to by
40 .IR sem .
41 If the semaphore's value consequently becomes greater than zero,
42 then another process or thread blocked in a
43 .BR sem_wait (3)
44 call will be woken up and proceed to lock the semaphore.
45 .SH RETURN VALUE
46 .BR sem_post ()
47 returns 0 on success;
48 on error, the value of the semaphore is left unchanged,
49 \-1 is returned, and
50 .I errno
51 is set to indicate the error.
52 .SH ERRORS
53 .TP
54 .B EINVAL
55 .I sem
56 is not a valid semaphore.
57 .TP
58 .B EOVERFLOW
59 .\" Added in POSIX.1-2008 TC1 (Austin Interpretation 213)
60 The maximum allowable value for a semaphore would be exceeded.
61 .SH ATTRIBUTES
62 .SS Multithreading (see pthreads(7))
63 The
64 .BR sem_post ()
65 function is thread-safe.
66 .SH CONFORMING TO
67 POSIX.1-2001.
68 .SH NOTES
69 .BR sem_post ()
70 is async-signal-safe:
71 it may be safely called within a signal handler.
72 .SH EXAMPLE
73 See
74 .BR sem_wait (3).
75 .SH SEE ALSO
76 .BR sem_getvalue (3),
77 .BR sem_wait (3),
78 .BR sem_overview (7)
79 .SH COLOPHON
80 This page is part of release 3.68 of the Linux
81 .I man-pages
82 project.
83 A description of the project,
84 information about reporting bugs,
85 and the latest version of this page,
86 can be found at
87 \%http://www.kernel.org/doc/man\-pages/.