nightly: remove unused BINARCHIVE
[unleashed.git] / share / man / man3c / pthread_mutex_timedlock.3c
blob0ad5340e57f8412ffb5c74459dcc46b8219060a4
1 .\"
2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3 .\" permission to reproduce portions of its copyrighted documentation.
4 .\" Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
6 .\"
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
9 .\" documentation.
10 .\"
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
13 .\"
14 .\" Portions of this text are reprinted and reproduced in electronic form
15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16 .\" Standard for Information Technology -- Portable Operating System
17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19 .\" Engineers, Inc and The Open Group.  In the event of any discrepancy
20 .\" between these versions and the original IEEE and The Open Group
21 .\" Standard, the original IEEE and The Open Group Standard is the referee
22 .\" document.  The original Standard can be obtained online at
23 .\" http://www.opengroup.org/unix/online.html.
24 .\"
25 .\" This notice shall appear on any product containing this material.
26 .\"
27 .\" The contents of this file are subject to the terms of the
28 .\" Common Development and Distribution License (the "License").
29 .\" You may not use this file except in compliance with the License.
30 .\"
31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 .\" or http://www.opensolaris.org/os/licensing.
33 .\" See the License for the specific language governing permissions
34 .\" and limitations under the License.
35 .\"
36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38 .\" If applicable, add the following below this CDDL HEADER, with the
39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
41 .\"
42 .\"
43 .\" Copyright (c) 2001, The IEEE and The Open Group.  All Rights Reserved.
44 .\" Portions Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved.
45 .\"
46 .TH PTHREAD_MUTEX_TIMEDLOCK 3C "Jun 5, 2007"
47 .SH NAME
48 pthread_mutex_timedlock, pthread_mutex_reltimedlock_np \- lock a mutex
49 .SH SYNOPSIS
50 .LP
51 .nf
52 cc \fB-mt\fR [ \fIflag\fR... ] \fIfile\fR... [ \fIlibrary\fR... ]
53 #include <pthread.h>
54 #include <time.h>
56 \fBint\fR \fBpthread_mutex_timedlock\fR(\fBpthread_mutex_t *restrict\fR \fImutex\fR,
57      \fBconst struct timespec *restrict\fR \fIabs_timeout\fR);
58 .fi
60 .LP
61 .nf
62 \fBint\fR \fBpthread_mutex_reltimedlock_np\fR(\fBpthread_mutex_t *restrict\fR \fImutex\fR,
63      \fBconst struct timespec *restrict\fR \fIrel_timeout\fR);
64 .fi
66 .SH DESCRIPTION
67 .sp
68 .LP
69 The \fBpthread_mutex_timedlock()\fR function locks the mutex object referenced
70 by \fImutex\fR. If the mutex is already locked, the calling thread blocks until
71 the mutex becomes available as in the \fBpthread_mutex_lock\fR(3C). If the
72 mutex cannot be locked without waiting for another thread to unlock the mutex,
73 this wait is terminated when the specified timeout expires.
74 .sp
75 .LP
76 The \fBpthread_mutex_reltimedlock_np()\fR function is identical to the
77 \fBpthread_mutex_timedlock()\fR function, except that the timeout is specified
78 as a relative time interval.
79 .sp
80 .LP
81 For \fBpthread_mutex_timedlock()\fR, the timeout expires when the absolute time
82 specified by \fIabs_timeout\fR passes, as measured by the clock on which
83 timeouts are based (that is, when the value of that clock equals or exceeds
84 \fIabs_timeout\fR), or if the absolute time specified by \fIabs_timeout\fR has
85 already been passed at the time of the call.
86 .sp
87 .LP
88 For \fBpthread_mutex_reltimedlock_np()\fR, the timeout expires when the time
89 interval specified by \fIrel_timeout\fR passes, as measured by the
90 \fBCLOCK_REALTIME\fR clock, or if the time interval specified by
91 \fIrel_timeout\fR is negative at the time of the call.
92 .sp
93 .LP
94 The resolution of the timeout is the resolution of the \fBCLOCK_REALTIME\fR
95 clock. The \fBtimespec\fR data type is defined in the \fB<time.h>\fRheader.
96 .sp
97 .LP
98 Under no circumstance will either function fail with a timeout if the mutex can
99 be locked immediately. The validity of the \fItimeout\fR parameter is not
100 checked if the mutex can be locked immediately.
103 As a consequence of the priority inheritance rules (for mutexes initialized
104 with the \fBPRIO_INHERIT\fR protocol), if a timed mutex wait is terminated
105 because its timeout expires, the priority of the owner of the mutex is adjusted
106 as necessary to reflect the fact that this thread is no longer among the
107 threads waiting for the mutex.
108 .SH RETURN VALUES
111 Upon successful completion, the \fBpthread_mutex_timedlock()\fR and
112 \fBpthread_mutex_reltimedlock_np()\fR functions return 0. Otherwise, an error
113 number is returned to indicate the error.
114 .SH ERRORS
117 The \fBpthread_mutex_timedlock()\fR and \fBpthread_mutex_reltimedlock_np()\fR
118 functions will fail for the same reasons as \fBpthread_mutex_lock\fR(3C). In
119 addition, they will fail if:
121 .ne 2
123 \fB\fBEINVAL\fR\fR
125 .RS 13n
126 The caller would have blocked and the \fItimeout\fR parameter specified a
127 nanoseconds field value less than zero or greater than or equal to 1,000
128 million.
132 .ne 2
134 \fB\fBETIMEDOUT\fR\fR
136 .RS 13n
137 The mutex could not be locked before the specified \fItimeout\fR expired.
140 .SH ATTRIBUTES
143 See \fBattributes\fR(5) for descriptions of the following attributes:
148 box;
149 c | c
150 l | l .
151 ATTRIBUTE TYPE  ATTRIBUTE VALUE
153 Interface Stability     See below.
155 MT-Level        MT-Safe
160 The \fBpthread_mutex_timedlock()\fR is Standard. The
161 \fBpthread_mutex_reltimedlock_np()\fR function is Stable.
162 .SH SEE ALSO
165 \fBtime\fR(2), \fBpthread_mutex_destroy\fR(3C), \fBpthread_mutex_lock\fR(3C),
166 \fBpthread_mutex_trylock\fR(3C), \fBattributes\fR(5), \fBstandards\fR(5)