1ec2456e2SMike Makonnen.\" Copyright (c) 2003 Michael Telahun Makonnen 2ec2456e2SMike Makonnen.\" All rights reserved. 3ec2456e2SMike Makonnen.\" 4ec2456e2SMike Makonnen.\" Redistribution and use in source and binary forms, with or without 5ec2456e2SMike Makonnen.\" modification, are permitted provided that the following conditions 6ec2456e2SMike Makonnen.\" are met: 7ec2456e2SMike Makonnen.\" 1. Redistributions of source code must retain the above copyright 8ec2456e2SMike Makonnen.\" notice, this list of conditions and the following disclaimer. 9ec2456e2SMike Makonnen.\" 2. Redistributions in binary form must reproduce the above copyright 10ec2456e2SMike Makonnen.\" notice, this list of conditions and the following disclaimer in the 11ec2456e2SMike Makonnen.\" documentation and/or other materials provided with the distribution. 12ec2456e2SMike Makonnen.\" 13ec2456e2SMike Makonnen.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14ec2456e2SMike Makonnen.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15ec2456e2SMike Makonnen.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16ec2456e2SMike Makonnen.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17ec2456e2SMike Makonnen.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18ec2456e2SMike Makonnen.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19ec2456e2SMike Makonnen.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20ec2456e2SMike Makonnen.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21ec2456e2SMike Makonnen.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22ec2456e2SMike Makonnen.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23ec2456e2SMike Makonnen.\" SUCH DAMAGE. 24ec2456e2SMike Makonnen.\" 25ec2456e2SMike Makonnen.\" $FreeBSD$ 26ec2456e2SMike Makonnen.\" 27ec2456e2SMike Makonnen.Dd December 30, 2003 28ec2456e2SMike Makonnen.Dt PTHREAD_MUTEX_TIMEDLOCK 3 29ec2456e2SMike Makonnen.Os 30ec2456e2SMike Makonnen.Sh NAME 31ec2456e2SMike Makonnen.Nm pthread_mutex_timedlock 32ec2456e2SMike Makonnen.Nd lock a mutex without blocking indefinitely 33ec2456e2SMike Makonnen.Sh LIBRARY 34ec2456e2SMike Makonnen.Lb libc_r 35ec2456e2SMike Makonnen.Sh SYNOPSIS 36ec2456e2SMike Makonnen.In pthread.h 37ec2456e2SMike Makonnen.In time.h 38ec2456e2SMike Makonnen.Ft int 39ec2456e2SMike Makonnen.Fn pthread_mutex_timedlock "pthread_mutex_t *mutex" "const struct timespec *abs_timeout" 40ec2456e2SMike Makonnen.Sh DESCRIPTION 41ec2456e2SMike MakonnenThe 42ec2456e2SMike Makonnen.Fn pthread_mutex_timedlock 43ec2456e2SMike Makonnenfunction will lock 44ec2456e2SMike Makonnen.Fa mutex . 45ec2456e2SMike MakonnenIf it is already locked the calling thread will block until 46ec2456e2SMike Makonnenthe mutex becomes available or 47ec2456e2SMike Makonnenthe timeout, 48ec2456e2SMike Makonnenspecified by abs_timeout, 49ec2456e2SMike Makonnenexpires. 50ec2456e2SMike MakonnenThe time of the timeout is an absolute time and 51ec2456e2SMike Makonnenis not relative to the current time. 52ec2456e2SMike Makonnen.Sh IMPLEMENTATION NOTES 53ec2456e2SMike MakonnenThe 54ec2456e2SMike Makonnen.Fn pthread_mutex_timedlock 55ec2456e2SMike Makonnenfunction is only available in 56ec2456e2SMike Makonnen.Lb libkse 57ec2456e2SMike Makonnenand 58ec2456e2SMike Makonnen.Lb libthr . 59ec2456e2SMike MakonnenThis function is not implemented in 60ec2456e2SMike Makonnen.Lb libc_r . 61ec2456e2SMike Makonnen.Sh RETURN VALUES 62ec2456e2SMike MakonnenIf successful, 63ec2456e2SMike Makonnen.Fn pthread_mutex_timedlock 64ec2456e2SMike Makonnenwill return zero, otherwise an error number will be returned to 65ec2456e2SMike Makonnenindicate the error. 66ec2456e2SMike Makonnen.Sh ERRORS 67ec2456e2SMike MakonnenThe 68ec2456e2SMike Makonnen.Fn pthread_mutex_timedlock 69ec2456e2SMike Makonnenfunction will fail if: 70ec2456e2SMike Makonnen.Bl -tag -width Er 71ec2456e2SMike Makonnen.It Bq Er EINVAL 72ec2456e2SMike MakonnenThe 73ec2456e2SMike Makonnen.Fa mutex 74ec2456e2SMike Makonnenwas created with the protocol attribute having the 75ec2456e2SMike Makonnenvalue PTHREAD_PRIO_PROTECT and 76ec2456e2SMike Makonnenthe calling thread's priority is higher than the 77ec2456e2SMike Makonnenmutex's current priority ceiling. 78ec2456e2SMike Makonnen.It Bq Er EINVAL 79ec2456e2SMike MakonnenThe process or thread would have blocked, and 80ec2456e2SMike Makonnen.Fa abs_timeout 81ec2456e2SMike Makonnenspecified a nanosecond value less than zero or 82ec2456e2SMike Makonnengreater than or equal to 1 billion. 83ec2456e2SMike Makonnen.It Bq Er EINVAL 84ec2456e2SMike MakonnenThe 85ec2456e2SMike Makonnen.Fa mutex 86ec2456e2SMike Makonnenparameter is invalid. 87ec2456e2SMike Makonnen.It Bq Er ETIMEDOUT 88ec2456e2SMike MakonnenThe 89ec2456e2SMike Makonnen.Fa mutex 90ec2456e2SMike Makonnencould not be locked before the timeout expired. 91ec2456e2SMike Makonnen.It Bq Er EAGAIN 92ec2456e2SMike MakonnenThe 93ec2456e2SMike Makonnen.Fa mutex 94ec2456e2SMike Makonnencould not be acquired because the 95ec2456e2SMike Makonnenmaximum number of recursive locks for the 96ec2456e2SMike Makonnen.Fa mutex 97ec2456e2SMike Makonnenhas been exceeded. 98ec2456e2SMike Makonnen.It Bq Er EDEADLK 99ec2456e2SMike MakonnenThe current thread already owns the 100ec2456e2SMike Makonnen.Fa mutex . 101ec2456e2SMike Makonnen.El 102ec2456e2SMike Makonnen.Sh SEE ALSO 103ec2456e2SMike Makonnen.Xr pthread_mutex_destroy 3 , 104ec2456e2SMike Makonnen.Xr pthread_mutex_init 3 , 105ec2456e2SMike Makonnen.Xr pthread_mutex_lock 3 , 106ec2456e2SMike Makonnen.Xr pthread_mutex_trylock 3 , 107ec2456e2SMike Makonnen.Xr pthread_mutex_unlock 3 108ec2456e2SMike Makonnen.Sh STANDARDS 109ec2456e2SMike MakonnenThe 110ec2456e2SMike Makonnen.Fn pthread_mutex_timedlock 111ec2456e2SMike Makonnenfunction is expected to conform to 112ec2456e2SMike Makonnen.St -p1003.1-96 . 113