summaryrefslogtreecommitdiff
path: root/usr/src/man/man2/_lwp_cond_wait.2
diff options
context:
space:
mode:
authorRichard Lowe <richlowe@richlowe.net>2011-03-14 14:05:30 -0400
committerRichard Lowe <richlowe@richlowe.net>2011-03-14 14:05:30 -0400
commitc10c16dec587a0662068f6e2991c29ed3a9db943 (patch)
treef414286f4bba41d75683ed4fbbaa6bfa4bf7fabd /usr/src/man/man2/_lwp_cond_wait.2
parent68caef18a23a498d9e3017b983562c0f4fd8ab23 (diff)
downloadillumos-joyent-c10c16dec587a0662068f6e2991c29ed3a9db943.tar.gz
243 system manual pages should live with the software
Reviewed by: garrett@nexenta.com Reviewed by: gwr@nexenta.com Reviewed by: trisk@opensolaris.org Approved by: gwr@nexenta.com --HG-- extra : rebase_source : 0c599d0bec0dc8865fbba67721a7a6cd6b1feefb
Diffstat (limited to 'usr/src/man/man2/_lwp_cond_wait.2')
-rw-r--r--usr/src/man/man2/_lwp_cond_wait.2220
1 files changed, 220 insertions, 0 deletions
diff --git a/usr/src/man/man2/_lwp_cond_wait.2 b/usr/src/man/man2/_lwp_cond_wait.2
new file mode 100644
index 0000000000..e6d6c33002
--- /dev/null
+++ b/usr/src/man/man2/_lwp_cond_wait.2
@@ -0,0 +1,220 @@
+'\" te
+.\" Copyright (c) 2001, Sun Microsystems, Inc. All Rights Reserved
+.\" 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.
+.\" 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.
+.\" 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]
+.TH _lwp_cond_wait 2 "13 Apr 2001" "SunOS 5.11" "System Calls"
+.SH NAME
+_lwp_cond_wait, _lwp_cond_timedwait, _lwp_cond_reltimedwait \- wait on a
+condition variable
+.SH SYNOPSIS
+.LP
+.nf
+#include <sys/lwp.h>
+
+\fBint\fR \fB_lwp_cond_wait\fR(\fBlwp_cond_t *\fR\fIcvp\fR, \fBlwp_mutex_t *\fR\fImp\fR);
+.fi
+
+.LP
+.nf
+\fBint\fR \fB_lwp_cond_timedwait\fR(\fBlwp_cond_t *\fR\fIcvp\fR, \fBlwp_mutex_t *\fR\fImp\fR,
+ \fBtimestruc_t *\fR\fIabstime\fR);
+.fi
+
+.LP
+.nf
+\fBint\fR \fB_lwp_cond_reltimedwait\fR(\fBlwp_cond_t *\fR\fIcvp\fR, \fBlwp_mutex_t *\fR\fImp\fR,
+ \fBtimestruc_t *\fR\fIreltime\fR);
+.fi
+
+.SH DESCRIPTION
+.sp
+.LP
+These functions are used to wait for the occurrence of a condition represented
+by an LWP condition variable. LWP condition variables must be initialized to 0
+before use.
+.sp
+.LP
+The \fB_lwp_cond_wait()\fR function atomically releases the LWP mutex pointed
+to by \fImp\fR and causes the calling LWP to block on the LWP condition
+variable pointed to by \fIcvp\fR. The blocked LWP may be awakened by
+\fB_lwp_cond_signal\fR(2), \fB_lwp_cond_broadcast\fR(2), or when interrupted by
+delivery of a signal. Any change in value of a condition associated with the
+condition variable cannot be inferred by the return of \fB_lwp_cond_wait()\fR
+and any such condition must be re-evaluated.
+.sp
+.LP
+The \fB_lwp_cond_timedwait()\fR function is similar to \fB_lwp_cond_wait()\fR,
+except that the calling LWP will not block past the time of day specified by
+\fIabstime\fR. If the time of day becomes greater than \fIabstime\fR,
+\fB_lwp_cond_timedwait()\fR returns with the error code \fBETIME\fR.
+.sp
+.LP
+The \fB_lwp_cond_reltimedwait()\fR function is similar to
+\fB_lwp_cond_wait()\fR, except that the calling LWP will not block past the
+relative time specified by \fIreltime\fR. If the time of day becomes greater
+than the starting time of day plus \fIreltime\fR,
+\fB_lwp_cond_reltimedwait()\fR returns with the error code \fBETIME\fR.
+.sp
+.LP
+The \fB_lwp_cond_wait()\fR, \fB_lwp_cond_timedwait()\fR, and
+\fB_lwp_cond_reltimedwait()\fR functions always return with the mutex locked
+and owned by the calling lightweight process.
+.SH RETURN VALUES
+.sp
+.LP
+Upon successful completion, \fB0\fR is returned. A non-zero value indicates an
+error.
+.SH ERRORS
+.sp
+.LP
+If any of the following conditions are detected, \fB_lwp_cond_wait()\fR,
+\fB_lwp_cond_timedwait()\fR, and \fB_lwp_cond_reltimedwait()\fR fail and return
+the corresponding value:
+.sp
+.ne 2
+.mk
+.na
+\fB\fBEINVAL\fR\fR
+.ad
+.RS 10n
+.rt
+The \fIcvp\fR argument points to an invalid LWP condition variable or the
+\fImp\fR argument points to an invalid LWP mutex.
+.RE
+
+.sp
+.ne 2
+.mk
+.na
+\fB\fBEFAULT\fR\fR
+.ad
+.RS 10n
+.rt
+The \fImp\fR, \fIcvp\fR, or \fIabstime\fR argument points to an illegal
+address.
+.RE
+
+.sp
+.LP
+If any of the following conditions occur, \fB_lwp_cond_wait()\fR,
+\fB_lwp_cond_timedwait()\fR, and \fB_lwp_cond_reltimedwait()\fR fail and return
+the corresponding value:
+.sp
+.ne 2
+.mk
+.na
+\fB\fBEINTR\fR\fR
+.ad
+.RS 9n
+.rt
+The call was interrupted by a signal or \fBfork\fR(2).
+.RE
+
+.sp
+.LP
+If any of the following conditions occur, \fB_lwp_cond_timedwait()\fR and
+\fB_lwp_cond_reltimedwait()\fR fail and return the corresponding value:
+.sp
+.ne 2
+.mk
+.na
+\fB\fBETIME\fR\fR
+.ad
+.RS 9n
+.rt
+The time specified in\fIabstime\fR or \fIreltime\fR has passed.
+.RE
+
+.SH EXAMPLES
+.LP
+\fBExample 1 \fRUse the \fB_lwp_cond_wait()\fR function in a loop testing some
+condition.
+.sp
+.LP
+The \fB_lwp_cond_wait()\fR function is normally used in a loop testing some
+condition, as follows:
+
+.sp
+.in +2
+.nf
+lwp_mutex_t m;
+lwp_cond_t cv;
+int cond;
+(void) _lwp_mutex_lock(&m);
+while (cond == FALSE) {
+ (void) _lwp_cond_wait(&cv, &m);
+}
+(void) _lwp_mutex_unlock(&m);
+.fi
+.in -2
+
+.LP
+\fBExample 2 \fRUse the \fB_lwp_cond_timedwait()\fR function in a loop testing
+some condition.
+.sp
+.LP
+The \fB_lwp_cond_timedwait()\fR function is also normally used in a loop
+testing some condition. It uses an absolute timeout value as follows:
+
+.sp
+.in +2
+.nf
+timestruc_t to;
+lwp_mutex_t m;
+lwp_cond_t cv;
+int cond, err;
+(void) _lwp_mutex_lock(&m);
+to.tv_sec = time(NULL) + TIMEOUT;
+to.tv_nsec = 0;
+while (cond == FALSE) {
+ err = _lwp_cond_timedwait(&cv, &m, &to);
+ if (err == ETIME) {
+ /* timeout, do something */
+ break;
+ SENDwhom}
+}
+(void) _lwp_mutex_unlock(&m);
+.fi
+.in -2
+
+.sp
+.LP
+This example sets a bound on the total wait time even though the
+\fB_lwp_cond_timedwait()\fR may return several times due to the condition being
+signalled or the wait being interrupted.
+
+.LP
+\fBExample 3 \fRUse the \fB_lwp_cond_reltimedwait()\fR function in a loop
+testing some condition.
+.sp
+.LP
+The \fB_lwp_cond_reltimedwait()\fR function is also normally used in a loop
+testing some condition. It uses a relative timeout value as follows:
+
+.sp
+.in +2
+.nf
+timestruc_t to;
+lwp_mutex_t m;
+lwp_cond_t cv;
+int cond, err;
+(void) _lwp_mutex_lock(&m);
+while (cond == FALSE) {
+ to.tv_sec = TIMEOUT;
+ to.tv_nsec = 0;
+ err = _lwp_cond_reltimedwait(&cv, &m, &to);
+ if (err == ETIME) {
+ /* timeout, do something */
+ break;
+ }
+}
+(void) _lwp_mutex_unlock(&m);
+.fi
+.in -2
+
+.SH SEE ALSO
+.sp
+.LP
+\fB_lwp_cond_broadcast\fR(2), \fB_lwp_cond_signal\fR(2), \fB_lwp_kill\fR(2),
+\fB_lwp_mutex_lock\fR(2), \fBfork\fR(2), \fBkill\fR(2)