PTHREAD_MUTEXATTR(3) | MidnightBSD Library Functions Manual | PTHREAD_MUTEXATTR(3) |
pthread_mutexattr_init
,
pthread_mutexattr_destroy
,
pthread_mutexattr_setprioceiling
,
pthread_mutexattr_getprioceiling
,
pthread_mutexattr_setprotocol
,
pthread_mutexattr_getprotocol
,
pthread_mutexattr_setpshared
,
pthread_mutexattr_getpshared
,
pthread_mutexattr_setrobust
,
pthread_mutexattr_getrobust
,
pthread_mutexattr_settype
,
pthread_mutexattr_gettype
—
mutex attribute operations
POSIX Threads Library (libpthread, -lpthread)
#include
<pthread.h>
int
pthread_mutexattr_init
(pthread_mutexattr_t
*attr);
int
pthread_mutexattr_destroy
(pthread_mutexattr_t
*attr);
int
pthread_mutexattr_setprioceiling
(pthread_mutexattr_t
*attr, int prioceiling);
int
pthread_mutexattr_getprioceiling
(const
pthread_mutexattr_t *attr, int
*prioceiling);
int
pthread_mutexattr_setprotocol
(pthread_mutexattr_t
*attr, int
protocol);
int
pthread_mutexattr_getprotocol
(const
pthread_mutexattr_t *restrict attr, int *restrict
protocol);
int
pthread_mutexattr_setpshared
(pthread_mutexattr_t
*attr, int shared);
int
pthread_mutexattr_getpshared
(const
pthread_mutexattr_t *attr, int *shared);
int
pthread_mutexattr_setrobust
(pthread_mutexattr_t
*attr, int
robust);
int
pthread_mutexattr_getrobust
(pthread_mutexattr_t
*attr, int
*robust);
int
pthread_mutexattr_settype
(pthread_mutexattr_t
*attr, int
type);
int
pthread_mutexattr_gettype
(const
pthread_mutexattr_t *restrict attr, int *restrict
type);
Mutex attributes are used to specify parameters to
pthread_mutex_init
().
One attribute object can be used in multiple calls to
pthread_mutex_init
(), with or without modifications
between calls.
The
pthread_mutexattr_init
()
function initializes attr with all the default mutex
attributes.
The
pthread_mutexattr_destroy
()
function destroys attr.
The
pthread_mutexattr_setprioceiling
()
function sets the priority ceiling for the mutex, used by threads executed
under the PTHREAD_PRIO_PROTECT
protocol.
The
pthread_mutexattr_setprotocol
()
function specifies the protocol to be followed in utilizing mutexes. The
protocol argument can take one of the following
values:
The
pthread_mutexattr_setrobust
()
function specifies robustness attribute of the mutex. Possible values for
the robust argument are
EOWNERDEAD
from the locking function. Then, either
pthread_mutex_consistent(3)
can be used to repair the mutex lock state, or
pthread_mutex_unlock(3)
can unlock the mutex lock but also put it an unusable state, where all
further attempts to acquire it result in the
ENOTRECOVERABLE
error.The
pthread_mutexattr_settype
()
function sets the type of the mutex. The type affects the behavior of calls
which lock and unlock the mutex. The possible values for the
type argument are
PTHREAD_MUTEX_ERRORCHECK
but somewhat contradicts the behavior mandated by POSIX.PTHREAD_MUTEX_ERRORCHECK
type.The
pthread_mutexattr_get*
()
functions copy the value of the attribute that corresponds to each function
name to the location pointed to by the second function parameter.
If successful, these functions return 0. Otherwise, an error number is returned to indicate the error.
The pthread_mutexattr_init
() function will
fail if:
ENOMEM
]The pthread_mutexattr_destroy
() function
will fail if:
EINVAL
]The pthread_mutexattr_setprioceiling
()
function will fail if:
EINVAL
]The pthread_mutexattr_getprioceiling
()
function will fail if:
EINVAL
]The pthread_mutexattr_setprotocol
()
function will fail if:
EINVAL
]The pthread_mutexattr_getprotocol
()
function will fail if:
EINVAL
]The pthread_mutexattr_setpshared
()
function will fail if:
EINVAL
]The pthread_mutexattr_getpshared
()
function will fail if:
EINVAL
]The pthread_mutexattr_settype
() function
will fail if:
EINVAL
]The pthread_mutexattr_gettype
() function
will fail if:
EINVAL
]The pthread_mutexattr_setrobust
() function
will fail if:
EINVAL
]The pthread_mutexattr_getrobust
() function
will fail if:
EINVAL
]The pthread_mutexattr_init
() and
pthread_mutexattr_destroy
() functions conform to
ISO/IEC 9945-1:1996 (“POSIX.1”)
The pthread_mutexattr_setprioceiling
(),
pthread_mutexattr_getprioceiling
(),
pthread_mutexattr_setprotocol
(),
pthread_mutexattr_getprotocol
(),
pthread_mutexattr_setpshared
(),
pthread_mutexattr_getpshared
(),
pthread_mutexattr_settype
(), and
pthread_mutexattr_gettype
() functions conform to
Version 2 of the Single UNIX Specification
(“SUSv2”). The
pthread_mutexattr_setrobust
() and
pthread_mutexattr_getrobust
() functions conform to
Version 4 of the Single UNIX Specification
(“SUSv4”).
October 1, 2021 | midnightbsd-3.1 |