11fbdc08dSPoul-Henning Kamp.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com> 21fbdc08dSPoul-Henning Kamp.\" All rights reserved. 31fbdc08dSPoul-Henning Kamp.\" 41fbdc08dSPoul-Henning Kamp.\" Redistribution and use in source and binary forms, with or without 51fbdc08dSPoul-Henning Kamp.\" modification, are permitted provided that the following conditions 61fbdc08dSPoul-Henning Kamp.\" are met: 71fbdc08dSPoul-Henning Kamp.\" 1. Redistributions of source code must retain the above copyright 81fbdc08dSPoul-Henning Kamp.\" notice, this list of conditions and the following disclaimer. 91fbdc08dSPoul-Henning Kamp.\" 2. Redistributions in binary form must reproduce the above copyright 101fbdc08dSPoul-Henning Kamp.\" notice, this list of conditions and the following disclaimer in the 111fbdc08dSPoul-Henning Kamp.\" documentation and/or other materials provided with the distribution. 121fbdc08dSPoul-Henning Kamp.\" 3. Neither the name of the author nor the names of any co-contributors 131fbdc08dSPoul-Henning Kamp.\" may be used to endorse or promote products derived from this software 141fbdc08dSPoul-Henning Kamp.\" without specific prior written permission. 151fbdc08dSPoul-Henning Kamp.\" 161fbdc08dSPoul-Henning Kamp.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND 171fbdc08dSPoul-Henning Kamp.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 181fbdc08dSPoul-Henning Kamp.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 191fbdc08dSPoul-Henning Kamp.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 201fbdc08dSPoul-Henning Kamp.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 211fbdc08dSPoul-Henning Kamp.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 221fbdc08dSPoul-Henning Kamp.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 231fbdc08dSPoul-Henning Kamp.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 241fbdc08dSPoul-Henning Kamp.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 251fbdc08dSPoul-Henning Kamp.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 261fbdc08dSPoul-Henning Kamp.\" SUCH DAMAGE. 271fbdc08dSPoul-Henning Kamp.\" 28*febae919SJilles Tjoelker.Dd May 9, 2010 291fbdc08dSPoul-Henning Kamp.Dt PTHREAD_COND_TIMEDWAIT 3 30a307d598SRuslan Ermilov.Os 311fbdc08dSPoul-Henning Kamp.Sh NAME 321fbdc08dSPoul-Henning Kamp.Nm pthread_cond_timedwait 33f167d7fbSSheldon Hearn.Nd "wait on a condition variable for a specific amount of time" 34d8a78688SAlexey Zelkin.Sh LIBRARY 35ec7452f1SRuslan Ermilov.Lb libpthread 361fbdc08dSPoul-Henning Kamp.Sh SYNOPSIS 3732eef9aeSRuslan Ermilov.In pthread.h 381fbdc08dSPoul-Henning Kamp.Ft int 391fbdc08dSPoul-Henning Kamp.Fn pthread_cond_timedwait "pthread_cond_t *cond" "pthread_mutex_t *mutex" "const struct timespec *abstime" 401fbdc08dSPoul-Henning Kamp.Sh DESCRIPTION 411fbdc08dSPoul-Henning KampThe 421fbdc08dSPoul-Henning Kamp.Fn pthread_cond_timedwait 431fbdc08dSPoul-Henning Kampfunction atomically blocks the current thread waiting on the condition 441fbdc08dSPoul-Henning Kampvariable specified by 451fbdc08dSPoul-Henning Kamp.Fa cond , 46e4adaf64SWarner Loshand releases the mutex specified by 471fbdc08dSPoul-Henning Kamp.Fa mutex . 481fbdc08dSPoul-Henning KampThe waiting thread unblocks only after another thread calls 491fbdc08dSPoul-Henning Kamp.Xr pthread_cond_signal 3 , 501fbdc08dSPoul-Henning Kampor 511fbdc08dSPoul-Henning Kamp.Xr pthread_cond_broadcast 3 521fbdc08dSPoul-Henning Kampwith the same condition variable, or if the system time reaches the 531fbdc08dSPoul-Henning Kamptime specified in 541fbdc08dSPoul-Henning Kamp.Fa abstime , 55c1c5db81SGregory Neil Shapiroand the current thread reacquires the lock on 561fbdc08dSPoul-Henning Kamp.Fa mutex . 57*febae919SJilles Tjoelker.Pp 58*febae919SJilles TjoelkerThe clock used to measure 59*febae919SJilles Tjoelker.Fa abstime 60*febae919SJilles Tjoelkercan be specified during creation of the condition variable using 61*febae919SJilles Tjoelker.Xr pthread_condattr_setclock 3 . 621fbdc08dSPoul-Henning Kamp.Sh RETURN VALUES 631fbdc08dSPoul-Henning KampIf successful, the 641fbdc08dSPoul-Henning Kamp.Fn pthread_cond_timedwait 65c6ff3a1bSSheldon Hearnfunction will return zero. 66c6ff3a1bSSheldon HearnOtherwise an error number will be returned to 671fbdc08dSPoul-Henning Kampindicate the error. 681fbdc08dSPoul-Henning Kamp.Sh ERRORS 696f673fd1SPhilippe CharnierThe 701fbdc08dSPoul-Henning Kamp.Fn pthread_cond_timedwait 716f673fd1SPhilippe Charnierfunction will fail if: 721fbdc08dSPoul-Henning Kamp.Bl -tag -width Er 731fbdc08dSPoul-Henning Kamp.It Bq Er EINVAL 741fbdc08dSPoul-Henning KampThe value specified by 7549b1e06aSRalf S. Engelschall.Fa cond , 7649b1e06aSRalf S. Engelschall.Fa mutex 7749b1e06aSRalf S. Engelschallor 7849b1e06aSRalf S. Engelschall.Fa abstime 791fbdc08dSPoul-Henning Kampis invalid. 801fbdc08dSPoul-Henning Kamp.It Bq Er ETIMEDOUT 811fbdc08dSPoul-Henning KampThe system time has reached or exceeded the time specified in 821fbdc08dSPoul-Henning Kamp.Fa abstime . 83e4adaf64SWarner Losh.It Bq Er EPERM 84e4adaf64SWarner LoshThe specified 85e4adaf64SWarner Losh.Fa mutex 86e4adaf64SWarner Loshwas not locked by the calling thread. 871fbdc08dSPoul-Henning Kamp.El 881fbdc08dSPoul-Henning Kamp.Sh SEE ALSO 89acd80190SWolfram Schneider.Xr pthread_cond_broadcast 3 , 901fbdc08dSPoul-Henning Kamp.Xr pthread_cond_destroy 3 , 91acd80190SWolfram Schneider.Xr pthread_cond_init 3 , 921fbdc08dSPoul-Henning Kamp.Xr pthread_cond_signal 3 , 93*febae919SJilles Tjoelker.Xr pthread_cond_wait 3 , 94*febae919SJilles Tjoelker.Xr pthread_condattr_setclock 3 951fbdc08dSPoul-Henning Kamp.Sh STANDARDS 966f673fd1SPhilippe CharnierThe 971fbdc08dSPoul-Henning Kamp.Fn pthread_cond_timedwait 986f673fd1SPhilippe Charnierfunction conforms to 99096841ecSRuslan Ermilov.St -p1003.1-96 . 100