PTHREAD_MUTEXATTR_GETROBUST(P3O)SIX Programmer's ManPuTaHlREAD_MUTEXATTR_GETROBUST(3)



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


NNAAMMEE
       pthread_mutexattr_getrobust, pthread_mutexattr_setrobust -- get and set
       the mutex robust attribute

SSYYNNOOPPSSIISS
       #include <pthread.h>

       int pthread_mutexattr_getrobust(const pthread_mutexattr_t *restrict
           _a_t_t_r, int *restrict _r_o_b_u_s_t);
       int pthread_mutexattr_setrobust(pthread_mutexattr_t *_a_t_t_r,
           int _r_o_b_u_s_t);

DDEESSCCRRIIPPTTIIOONN
       The _p_t_h_r_e_a_d___m_u_t_e_x_a_t_t_r___g_e_t_r_o_b_u_s_t() and _p_t_h_r_e_a_d___m_u_t_e_x_a_t_t_r___s_e_t_r_o_b_u_s_t()
       functions, respectively, shall get and set the mutex _r_o_b_u_s_t attribute.
       This attribute is set in the _r_o_b_u_s_t parameter. Valid values for _r_o_b_u_s_t
       include:

       PTHREAD_MUTEX_STALLED
             No special actions are taken if the owner of the mutex is
             terminated while holding the mutex lock. This can lead to
             deadlocks if no other thread can unlock the mutex.
             This is the default value.

       PTHREAD_MUTEX_ROBUST
             If the process containing the owning thread of a robust mutex
             terminates while holding the mutex lock, the next thread that
             acquires the mutex shall be notified about the termination by the
             return value [[EEOOWWNNEERRDDEEAADD]] from the locking function. If the
             owning thread of a robust mutex terminates while holding the
             mutex lock, the next thread that acquires the mutex may be
             notified about the termination by the return value [[EEOOWWNNEERRDDEEAADD]].
             The notified thread can then attempt to mark the state protected
             by the mutex as consistent again by a call to
             _p_t_h_r_e_a_d___m_u_t_e_x___c_o_n_s_i_s_t_e_n_t().  After a subsequent successful call
             to _p_t_h_r_e_a_d___m_u_t_e_x___u_n_l_o_c_k(), the mutex lock shall be released and
             can be used normally by other threads. If the mutex is unlocked
             without a call to _p_t_h_r_e_a_d___m_u_t_e_x___c_o_n_s_i_s_t_e_n_t(), it shall be in a
             permanently unusable state and all attempts to lock the mutex
             shall fail with the error [[EENNOOTTRREECCOOVVEERRAABBLLEE]].  The only
             permissible operation on such a mutex is _p_t_h_r_e_a_d___m_u_t_e_x___d_e_s_t_r_o_y().

       The behavior is undefined if the value specified by the _a_t_t_r argument
       to _p_t_h_r_e_a_d___m_u_t_e_x_a_t_t_r___g_e_t_r_o_b_u_s_t() or _p_t_h_r_e_a_d___m_u_t_e_x_a_t_t_r___s_e_t_r_o_b_u_s_t() does
       not refer to an initialized mutex attributes object.

RREETTUURRNN VVAALLUUEE
       Upon successful completion, the _p_t_h_r_e_a_d___m_u_t_e_x_a_t_t_r___g_e_t_r_o_b_u_s_t() function
       shall return zero and store the value of the _r_o_b_u_s_t attribute of _a_t_t_r
       into the object referenced by the _r_o_b_u_s_t parameter. Otherwise, an error
       value shall be returned to indicate the error. If successful, the
       _p_t_h_r_e_a_d___m_u_t_e_x_a_t_t_r___s_e_t_r_o_b_u_s_t() function shall return zero; otherwise, an
       error number shall be returned to indicate the error.

EERRRROORRSS
       The _p_t_h_r_e_a_d___m_u_t_e_x_a_t_t_r___s_e_t_r_o_b_u_s_t() function shall fail if:

       EEIINNVVAALL The value of _r_o_b_u_s_t is invalid.

       These functions shall not return an error code of [[EEIINNTTRR]].

       _T_h_e _f_o_l_l_o_w_i_n_g _s_e_c_t_i_o_n_s _a_r_e _i_n_f_o_r_m_a_t_i_v_e_.

EEXXAAMMPPLLEESS
       None.

AAPPPPLLIICCAATTIIOONN UUSSAAGGEE
       The actions required to make the state protected by the mutex
       consistent again are solely dependent on the application. If it is not
       possible to make the state of a mutex consistent, robust mutexes can be
       used to notify this situation by calling _p_t_h_r_e_a_d___m_u_t_e_x___u_n_l_o_c_k() without
       a prior call to _p_t_h_r_e_a_d___m_u_t_e_x___c_o_n_s_i_s_t_e_n_t().

       If the state is declared inconsistent by calling _p_t_h_r_e_a_d___m_u_t_e_x___u_n_l_o_c_k()
       without a prior call to _p_t_h_r_e_a_d___m_u_t_e_x___c_o_n_s_i_s_t_e_n_t(), a possible approach
       could be to destroy the mutex and then reinitialize it. However, it
       should be noted that this is possible only in certain situations where
       the state protected by the mutex has to be reinitialized and
       coordination achieved with other threads blocked on the mutex, because
       otherwise a call to a locking function with a reference to a mutex
       object invalidated by a call to _p_t_h_r_e_a_d___m_u_t_e_x___d_e_s_t_r_o_y() results in
       undefined behavior.

RRAATTIIOONNAALLEE
       If an implementation detects that the value specified by the _a_t_t_r
       argument to _p_t_h_r_e_a_d___m_u_t_e_x_a_t_t_r___g_e_t_r_o_b_u_s_t() or
       _p_t_h_r_e_a_d___m_u_t_e_x_a_t_t_r___s_e_t_r_o_b_u_s_t() does not refer to an initialized mutex
       attributes object, it is recommended that the function should fail and
       report an [[EEIINNVVAALL]] error.

FFUUTTUURREE DDIIRREECCTTIIOONNSS
       None.

SSEEEE AALLSSOO
       _p_t_h_r_e_a_d___m_u_t_e_x___c_o_n_s_i_s_t_e_n_t(), _p_t_h_r_e_a_d___m_u_t_e_x___d_e_s_t_r_o_y(),
       _p_t_h_r_e_a_d___m_u_t_e_x___l_o_c_k()

       The Base Definitions volume of POSIX.1-2008, <<pptthhrreeaadd..hh>>

CCOOPPYYRRIIGGHHTT
       Portions of this text are reprinted and reproduced in electronic form
       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
       -- Portable Operating System Interface (POSIX), The Open Group Base
       Specifications Issue 7, Copyright (C) 2013 by the Institute of
       Electrical and Electronics Engineers, Inc and The Open Group.  (This is
       POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
       event of any discrepancy between this version and the original IEEE and
       The Open Group Standard, the original IEEE and The Open Group Standard
       is the referee document. The original Standard can be obtained online
       at http://www.unix.org/online.html .

       Any typographical or formatting errors that appear in this page are
       most likely to have been introduced during the conversion of the source
       files to man page format. To report such errors, see
       https://www.kernel.org/doc/man-pages/reporting_bugs.html .



IEEE/The Open Group                  2013       PTHREAD_MUTEXATTR_GETROBUST(3)
