Merge commit '9276b3991ba20d5a5660887ba81b0bc7bed25a0c'
[unleashed.git] / share / man / man3c / pthread_cond_signal.3c
blobd0aba675cb19f74bb1fbdef6fb03cdd104d10a1a
1 '\" te
2 .\" Copyright (c) 2008, Sun Microsystems, Inc.  All Rights Reserved.
3 .\" Copyright (c) 2001, the Institute of Electrical and Electronics Engineers, Inc. and The Open Group. All Rights Reserved.
4 .\" Copyright 1991, 1992, 1994, The X/Open Company Ltd.
5 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
6 .\" http://www.opengroup.org/bookstore/.
7 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
8 .\"  This notice shall appear on any product containing this material.
9 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
10 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
11 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
12 .TH PTHREAD_COND_SIGNAL 3C "Mar 23, 2005"
13 .SH NAME
14 pthread_cond_signal, pthread_cond_broadcast \- signal or broadcast a condition
15 .SH SYNOPSIS
16 .LP
17 .nf
18 cc -mt [ \fIflag\fR... ] \fIfile\fR... -lpthread [ \fIlibrary\fR... ]
19 #include <pthread.h>
21 \fBint\fR \fBpthread_cond_signal\fR(\fBpthread_cond_t *\fR\fIcond\fR);
22 .fi
24 .LP
25 .nf
26 \fBint\fR \fBpthread_cond_broadcast\fR(\fBpthread_cond_t *\fR\fIcond\fR);
27 .fi
29 .SH DESCRIPTION
30 .sp
31 .LP
32 These two functions are used to unblock threads blocked on a condition
33 variable.
34 .sp
35 .LP
36 The \fBpthread_cond_signal()\fR call unblocks at least one of the threads that
37 are blocked on the specified condition variable \fIcond\fR (if any threads are
38 blocked on \fIcond\fR).
39 .sp
40 .LP
41 The \fBpthread_cond_broadcast()\fR call unblocks all threads currently blocked
42 on the specified condition variable \fIcond\fR.
43 .sp
44 .LP
45 If more than one thread is blocked on a condition variable, the scheduling
46 policy determines the order in which threads are unblocked. When each thread
47 unblocked as a result of a \fBpthread_cond_signal()\fR or
48 \fBpthread_cond_broadcast()\fR returns from its call to
49 \fBpthread_cond_wait()\fR or \fBpthread_cond_timedwait()\fR, the thread owns
50 the mutex with which it called \fBpthread_cond_wait()\fR or
51 \fBpthread_cond_timedwait()\fR. The thread(s) that are unblocked contend for
52 the mutex according to the scheduling policy (if applicable), and as if each
53 had called \fBpthread_mutex_lock()\fR.
54 .sp
55 .LP
56 The \fBpthread_cond_signal()\fR or \fBpthread_cond_broadcast()\fR functions may
57 be called by a thread whether or not it currently owns the mutex that threads
58 calling \fBpthread_cond_wait()\fR or \fBpthread_cond_timedwait()\fR have
59 associated with the condition variable during their waits; however, if
60 predictable scheduling behavior is required, then that mutex is locked by the
61 thread calling \fBpthread_cond_signal()\fR or \fBpthread_cond_broadcast()\fR.
62 .sp
63 .LP
64 The \fBpthread_cond_signal()\fR and \fBpthread_cond_broadcast()\fR functions
65 have no effect if there are no threads currently blocked on \fIcond\fR.
66 .SH RETURN VALUES
67 .sp
68 .LP
69 If successful, the \fBpthread_cond_signal()\fR and
70 \fBpthread_cond_broadcast()\fR functions return  \fB0\fR. Otherwise, an error
71 number is returned to indicate the error.
72 .SH ERRORS
73 .sp
74 .LP
75 The  \fBpthread_cond_signal()\fR and \fBpthread_cond_broadcast()\fR function
76 may fail if:
77 .sp
78 .ne 2
79 .na
80 \fB\fBEINVAL\fR\fR
81 .ad
82 .RS 10n
83 The value \fIcond\fR does not refer to an initialized condition variable.
84 .RE
86 .SH ATTRIBUTES
87 .sp
88 .LP
89 See \fBattributes\fR(5) for descriptions of the following attributes:
90 .sp
92 .sp
93 .TS
94 box;
95 c | c
96 l | l .
97 ATTRIBUTE TYPE  ATTRIBUTE VALUE
99 Interface Stability     Standard
101 MT-Level        MT-Safe
104 .SH SEE ALSO
107 \fBpthread_cond_init\fR(3C), \fBpthread_cond_wait\fR(3C),
108 \fBpthread_cond_timedwait\fR(3C), \fBattributes\fR(5), \fBcondition\fR(5),
109 \fBstandards\fR(5)