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

NAME

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

SYNOPSIS

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

DESCRIPTION

24       The   pthread_mutexattr_getrobust()  and  pthread_mutexattr_setrobust()
25       functions, respectively, shall get and set the mutex robust  attribute.
26       This  attribute is set in the robust parameter. Valid values for robust
27       include:
28
29       PTHREAD_MUTEX_STALLED
30             No special actions are taken if the owner of the mutex is  termi‐
31             nated while holding the mutex lock. This can lead to deadlocks if
32             no other thread can unlock the mutex.
33             This is the default value.
34
35       PTHREAD_MUTEX_ROBUST
36             If the process containing the owning thread  of  a  robust  mutex
37             terminates  while  holding  the  mutex lock, the next thread that
38             acquires the mutex shall be notified about the termination by the
39             return  value [EOWNERDEAD] from the locking function. If the own‐
40             ing thread of a robust mutex terminates while holding  the  mutex
41             lock,  the  next thread that attempts to acquire the mutex may be
42             notified about the termination by the return value  [EOWNERDEAD].
43             The  notified thread can then attempt to make the state protected
44             by the mutex consistent again, and if  successful  can  mark  the
45             mutex  state as consistent by calling pthread_mutex_consistent().
46             After a subsequent successful call to pthread_mutex_unlock(), the
47             mutex  lock  shall  be released and can be used normally by other
48             threads.  If  the  mutex  is   unlocked   without   a   call   to
49             pthread_mutex_consistent(), it shall be in a permanently unusable
50             state and all attempts to lock the  mutex  shall  fail  with  the
51             error  [ENOTRECOVERABLE].  The only permissible operation on such
52             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‐2017, <pthread.h>
109
111       Portions  of  this text are reprinted and reproduced in electronic form
112       from IEEE Std 1003.1-2017, Standard for Information Technology --  Por‐
113       table  Operating System Interface (POSIX), The Open Group Base Specifi‐
114       cations Issue 7, 2018 Edition, Copyright (C) 2018 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       Any  typographical  or  formatting  errors that appear in this page are
122       most likely to have been introduced during the conversion of the source
123       files  to  man page format. To report such errors, see https://www.ker
124       nel.org/doc/man-pages/reporting_bugs.html .
125
126
127
128IEEE/The Open Group                  2017      PTHREAD_MUTEXATTR_GETROBUST(3P)
Impressum