1PTHREAD_MUTEX_TIMEDLOCK(3P)POSIX Programmer's ManualPTHREAD_MUTEX_TIMEDLOCK(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       pthread_mutex_timedlock - lock a mutex (ADVANCED REALTIME)
13

SYNOPSIS

15       #include <pthread.h>
16       #include <time.h>
17
18       int pthread_mutex_timedlock(pthread_mutex_t *restrict mutex,
19              const struct timespec *restrict abs_timeout);
20
21

DESCRIPTION

23       The pthread_mutex_timedlock() function shall lock the mutex object ref‐
24       erenced  by  mutex.  If the mutex is already locked, the calling thread
25       shall  block  until   the   mutex   becomes   available   as   in   the
26       pthread_mutex_lock()  function.  If  the mutex cannot be locked without
27       waiting for another thread to unlock the mutex, this wait shall be ter‐
28       minated when the specified timeout expires.
29
30       The  timeout shall expire when the absolute time specified by abs_time‐
31       out passes, as measured by the clock on which timeouts are based  (that
32       is,  when the value of that clock equals or exceeds abs_timeout), or if
33       the absolute time specified by abs_timeout has already been  passed  at
34       the time of the call.
35
36       If  the  Timers  option is supported, the timeout shall be based on the
37       CLOCK_REALTIME clock; if the Timers option is not supported, the  time‐
38       out  shall be based on the system clock as returned by the time() func‐
39       tion.
40
41       The resolution of the timeout shall be the resolution of the  clock  on
42       which  it  is  based. The timespec data type is defined in the <time.h>
43       header.
44
45       Under no circumstance shall the function fail with  a  timeout  if  the
46       mutex can be locked immediately. The validity of the abs_timeout param‐
47       eter need not be checked if the mutex can be locked immediately.
48
49       As a consequence of the priority inheritance rules  (for  mutexes  ini‐
50       tialized with the PRIO_INHERIT protocol), if a timed mutex wait is ter‐
51       minated because its timeout expires, the priority of the owner  of  the
52       mutex  shall  be  adjusted  as  necessary to reflect the fact that this
53       thread is no longer among the threads waiting for the mutex.
54

RETURN VALUE

56       If successful,  the  pthread_mutex_timedlock()  function  shall  return
57       zero;  otherwise,  an  error  number  shall be returned to indicate the
58       error.
59

ERRORS

61       The pthread_mutex_timedlock() function shall fail if:
62
63       EINVAL The mutex was created with the  protocol  attribute  having  the
64              value  PTHREAD_PRIO_PROTECT and the calling thread's priority is
65              higher than the mutex' current priority ceiling.
66
67       EINVAL The process or thread would have blocked,  and  the  abs_timeout
68              parameter  specified a nanoseconds field value less than zero or
69              greater than or equal to 1000 million.
70
71       ETIMEDOUT
72              The mutex could not  be  locked  before  the  specified  timeout
73              expired.
74
75
76       The pthread_mutex_timedlock() function may fail if:
77
78       EINVAL The  value  specified  by mutex does not refer to an initialized
79              mutex object.
80
81       EAGAIN The mutex could not be acquired because the  maximum  number  of
82              recursive locks for mutex has been exceeded.
83
84       EDEADLK
85              The current thread already owns the mutex.
86
87
88       This function shall not return an error code of [EINTR].
89
90       The following sections are informative.
91

EXAMPLES

93       None.
94

APPLICATION USAGE

96       The pthread_mutex_timedlock() function is part of the Threads and Time‐
97       outs options and need not be provided on all implementations.
98

RATIONALE

100       None.
101

FUTURE DIRECTIONS

103       None.
104

SEE ALSO

106       pthread_mutex_destroy(), pthread_mutex_lock(), pthread_mutex_trylock(),
107       time(),   the   Base   Definitions   volume   of  IEEE Std 1003.1-2001,
108       <pthread.h>, <time.h>
109
111       Portions of this text are reprinted and reproduced in  electronic  form
112       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
113       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
114       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
115       Electrical and Electronics Engineers, Inc and The Open  Group.  In  the
116       event of any discrepancy between this version and the original IEEE and
117       The Open Group Standard, the original IEEE and The Open Group  Standard
118       is  the  referee document. The original Standard can be obtained online
119       at http://www.opengroup.org/unix/online.html .
120
121
122
123IEEE/The Open Group                  2003          PTHREAD_MUTEX_TIMEDLOCK(3P)
Impressum