1PTHREAD_MUTEXATTR_GETROBUST(P3OPS)IX Programmer's MaPnTuHaRlEAD_MUTEXATTR_GETROBUST(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
11

NAME

13       pthread_mutexattr_getrobust, pthread_mutexattr_setrobust — get and  set
14       the mutex robust attribute
15

SYNOPSIS

17       #include <pthread.h>
18
19       int pthread_mutexattr_getrobust(const pthread_mutexattr_t *restrict
20           attr, int *restrict robust);
21       int pthread_mutexattr_setrobust(pthread_mutexattr_t *attr,
22           int robust);
23

DESCRIPTION

25       The   pthread_mutexattr_getrobust()  and  pthread_mutexattr_setrobust()
26       functions, respectively, shall get and set the mutex robust  attribute.
27       This  attribute is set in the robust parameter. Valid values for robust
28       include:
29
30       PTHREAD_MUTEX_STALLED
31             No special actions are taken if the owner of the mutex is  termi‐
32             nated while holding the mutex lock. This can lead to deadlocks if
33             no other thread can unlock the mutex.
34             This is the default value.
35
36       PTHREAD_MUTEX_ROBUST
37             If the process containing the owning thread  of  a  robust  mutex
38             terminates  while  holding  the  mutex lock, the next thread that
39             acquires the mutex shall be notified about the termination by the
40             return  value [EOWNERDEAD] from the locking function. If the own‐
41             ing thread of a robust mutex terminates while holding  the  mutex
42             lock,  the  next  thread  that acquires the mutex may be notified
43             about the termination by  the  return  value  [EOWNERDEAD].   The
44             notified  thread  can then attempt to mark the state protected by
45             the mutex as consistent again by a call to  pthread_mutex_consis‐
46             tent().      After    a    subsequent    successful    call    to
47             pthread_mutex_unlock(), the mutex lock shall be released and  can
48             be used normally by other threads. If the mutex is unlocked with‐
49             out a call to pthread_mutex_consistent(), it shall be in a perma‐
50             nently  unusable  state  and all attempts to lock the mutex shall
51             fail with the  error  [ENOTRECOVERABLE].   The  only  permissible
52             operation on such a mutex is pthread_mutex_destroy().
53
54       The  behavior  is undefined if the value specified by the attr argument
55       to pthread_mutexattr_getrobust() or pthread_mutexattr_setrobust()  does
56       not refer to an initialized mutex attributes object.
57

RETURN VALUE

59       Upon  successful completion, the pthread_mutexattr_getrobust() function
60       shall return zero and store the value of the robust attribute  of  attr
61       into the object referenced by the robust parameter. Otherwise, an error
62       value shall be returned to  indicate  the  error.  If  successful,  the
63       pthread_mutexattr_setrobust() function shall return zero; otherwise, an
64       error number shall be returned to indicate the error.
65

ERRORS

67       The pthread_mutexattr_setrobust() function shall fail if:
68
69       EINVAL The value of robust is invalid.
70
71       These functions shall not return an error code of [EINTR].
72
73       The following sections are informative.
74

EXAMPLES

76       None.
77

APPLICATION USAGE

79       The actions required to make the state protected by the  mutex  consis‐
80       tent again are solely dependent on the application. If it is not possi‐
81       ble to make the state of a mutex consistent, robust mutexes can be used
82       to  notify  this  situation by calling pthread_mutex_unlock() without a
83       prior call to pthread_mutex_consistent().
84
85       If the state is declared inconsistent by calling pthread_mutex_unlock()
86       without a prior call to pthread_mutex_consistent(), a possible approach
87       could be to destroy the mutex and then  reinitialize  it.  However,  it
88       should  be noted that this is possible only in certain situations where
89       the state protected by the mutex has to be reinitialized and  coordina‐
90       tion  achieved  with other threads blocked on the mutex, because other‐
91       wise a call to a locking function with a reference to  a  mutex  object
92       invalidated  by  a call to pthread_mutex_destroy() results in undefined
93       behavior.
94

RATIONALE

96       If an implementation detects that the value specified by the attr argu‐
97       ment  to pthread_mutexattr_getrobust() or pthread_mutexattr_setrobust()
98       does not refer to an initialized mutex attributes object, it is  recom‐
99       mended that the function should fail and report an [EINVAL] error.
100

FUTURE DIRECTIONS

102       None.
103

SEE ALSO

105       pthread_mutex_consistent(),                    pthread_mutex_destroy(),
106       pthread_mutex_lock()
107
108       The Base Definitions volume of POSIX.1‐2008, <pthread.h>
109
111       Portions of this text are reprinted and reproduced in  electronic  form
112       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
113       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
114       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
115       cal and Electronics Engineers,  Inc  and  The  Open  Group.   (This  is
116       POSIX.1-2008  with  the  2013  Technical Corrigendum 1 applied.) In the
117       event of any discrepancy between this version and the original IEEE and
118       The  Open Group Standard, the original IEEE and The Open Group Standard
119       is the referee document. The original Standard can be  obtained  online
120       at http://www.unix.org/online.html .
121
122       Any  typographical  or  formatting  errors that appear in this page are
123       most likely to have been introduced during the conversion of the source
124       files  to  man page format. To report such errors, see https://www.ker
125       nel.org/doc/man-pages/reporting_bugs.html .
126
127
128
129IEEE/The Open Group                  2013      PTHREAD_MUTEXATTR_GETROBUST(3P)
Impressum