1pthread_mutex_timedlock(3CS)tandard C Library Functionpsthread_mutex_timedlock(3C)
2
3
4

NAME

6       pthread_mutex_timedlock, pthread_mutex_reltimedlock_np - lock a mutex
7

SYNOPSIS

9       cc -mt [ flag... ] file... [ library... ]
10       #include <pthread.h>
11       #include <time.h>
12
13       int pthread_mutex_timedlock(pthread_mutex_t *restrict mutex,
14            const struct timespec *restrict abs_timeout);
15
16
17       int pthread_mutex_reltimedlock_np(pthread_mutex_t *restrict mutex,
18            const struct timespec *restrict rel_timeout);
19
20

DESCRIPTION

22       The  pthread_mutex_timedlock()  function  locks the mutex object refer‐
23       enced by mutex. If the mutex is  already  locked,  the  calling  thread
24       blocks    until    the    mutex    becomes    available   as   in   the
25       pthread_mutex_lock(3C). If the mutex cannot be locked  without  waiting
26       for  another  thread  to unlock the mutex, this wait is terminated when
27       the specified timeout expires.
28
29
30       The  pthread_mutex_reltimedlock_np()  function  is  identical  to   the
31       pthread_mutex_timedlock()  function,  except that the timeout is speci‐
32       fied as a relative time interval.
33
34
35       For pthread_mutex_timedlock(), the timeout expires  when  the  absolute
36       time specified by abs_timeout passes, as measured by the clock on which
37       timeouts are based (that is, when the value of  that  clock  equals  or
38       exceeds  abs_timeout), or if the absolute time specified by abs_timeout
39       has already been passed at the time of the call.
40
41
42       For pthread_mutex_reltimedlock_np(), the timeout expires when the  time
43       interval   specified   by   rel_timeout  passes,  as  measured  by  the
44       CLOCK_REALTIME clock, or if the time interval specified by  rel_timeout
45       is negative at the time of the call.
46
47
48       The  resolution  of the timeout is the resolution of the CLOCK_REALTIME
49       clock. The timespec data type is defined in the <time.h>header.
50
51
52       Under no circumstance will either function fail with a timeout  if  the
53       mutex  can be locked immediately. The validity of the timeout parameter
54       is not checked if the mutex can be locked immediately.
55
56
57       As a consequence of the priority inheritance rules  (for  mutexes  ini‐
58       tialized with the PRIO_INHERIT protocol), if a timed mutex wait is ter‐
59       minated because its timeout expires, the priority of the owner  of  the
60       mutex  is adjusted as necessary to reflect the fact that this thread is
61       no longer among the threads waiting for the mutex.
62

RETURN VALUES

64       Upon   successful   completion,   the   pthread_mutex_timedlock()   and
65       pthread_mutex_reltimedlock_np() functions return 0. Otherwise, an error
66       number is returned to indicate the error.
67

ERRORS

69       The pthread_mutex_timedlock() and pthread_mutex_reltimedlock_np() func‐
70       tions  will  fail  for  the  same reasons as pthread_mutex_lock(3C). In
71       addition, they will fail if:
72
73       EINVAL       The caller would have blocked and  the  timeout  parameter
74                    specified  a  nanoseconds  field  value  less than zero or
75                    greater than or equal to 1,000 million.
76
77
78       ETIMEDOUT    The mutex could not be locked before the specified timeout
79                    expired.
80
81

ATTRIBUTES

83       See attributes(5) for descriptions of the following attributes:
84
85
86
87
88       ┌─────────────────────────────┬─────────────────────────────┐
89       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
90       ├─────────────────────────────┼─────────────────────────────┤
91       │Interface Stability          │See below.                   │
92       ├─────────────────────────────┼─────────────────────────────┤
93       │MT-Level                     │MT-Safe                      │
94       └─────────────────────────────┴─────────────────────────────┘
95
96
97       The  pthread_mutex_timedlock() is Standard. The pthread_mutex_reltimed‐
98       lock_np() function is Stable.
99

SEE ALSO

101       time(2),       pthread_mutex_destroy(3C),       pthread_mutex_lock(3C),
102       pthread_mutex_trylock(3C), attributes(5), standards(5)
103
104
105
106SunOS 5.11                        5 Jun 2007       pthread_mutex_timedlock(3C)
Impressum