Standard C Library Functions pthreadmutextimedlock(3C)
NAME
pthreadmutextimedlock, pthreadmutexreltimedlocknp -
lock a mutex
SYNOPSIS
cc -mt [ flag... ] file... [ library... ]
#include
#include
int pthreadmutextimedlock(pthreadmutext *restrict mutex,
const struct timespec *restrict abstimeout);
int pthreadmutexreltimedlocknp(pthreadmutext *restrict mutex,
const struct timespec *restrict reltimeout);
DESCRIPTION
The pthreadmutextimedlock() function locks the mutex
object referenced by mutex. If the mutex is already locked,
the calling thread blocks until the mutex becomes available
as in the pthreadmutexlock(3C). If the mutex cannot be
locked without waiting for another thread to unlock the
mutex, this wait is terminated when the specified timeout
expires.
The pthreadmutexreltimedlocknp() function is identical to
the pthreadmutextimedlock() function, except that the
timeout is specified as a relative time interval.
For pthreadmutextimedlock(), the timeout expires when the
absolute time specified by abstimeout passes, as measured
by the clock on which timeouts are based (that is, when the
value of that clock equals or exceeds abstimeout), or if
the absolute time specified by abstimeout has already been
passed at the time of the call.
For pthreadmutexreltimedlocknp(), the timeout expires
when the time interval specified by reltimeout passes, as
measured by the CLOCKREALTIME clock, or if the time inter-
val specified by reltimeout is negative at the time of the
call.
The resolution of the timeout is the resolution of the
CLOCKREALTIME clock. The timespec data type is defined in
the header.
SunOS 5.11 Last change: 5 Jun 2007 1
Standard C Library Functions pthreadmutextimedlock(3C)
Under no circumstance will either function fail with a
timeout if the mutex can be locked immediately. The validity
of the timeout parameter is not checked if the mutex can be
locked immediately.
As a consequence of the priority inheritance rules (for
mutexes initialized with the PRIOINHERIT protocol), if a
timed mutex wait is terminated because its timeout expires,
the priority of the owner of the mutex is adjusted as neces-
sary to reflect the fact that this thread is no longer among
the threads waiting for the mutex.
RETURN VALUES
Upon successful completion, the pthreadmutextimedlock()
and pthreadmutexreltimedlocknp() functions return 0. Oth-
erwise, an error number is returned to indicate the error.
ERORS
The pthreadmutextimedlock() and
pthreadmutexreltimedlocknp() functions will fail for the
same reasons as pthreadmutexlock(3C). In addition, they
will fail if:
EINVAL The caller would have blocked and the timeout
parameter specified a nanoseconds field value
less than zero or greater than or equal to
1,000 million.
ETIMEDOUT The mutex could not be locked before the speci-
fied timeout expired.
ATRIBUTES
See attributes(5) for descriptions of the following attri-
butes:
ATRIBUTE TYPE ATRIBUTE VALUE
Interface Stability See below.
MT-Level MT-Safe
The pthreadmutextimedlock() is Standard. The
pthreadmutexreltimedlocknp() function is Stable.
SunOS 5.11 Last change: 5 Jun 2007 2
Standard C Library Functions pthreadmutextimedlock(3C)
SEE ALSO
time(2), pthreadmutexdestroy(3C), pthreadmutexlock(3C),
pthreadmutextrylock(3C), attributes(5), standards(5)
SunOS 5.11 Last change: 5 Jun 2007 3
|