1PTHREAD_MUTEXATTR_GETTYPE(3PP)OSIX Programmer's ManuPaTlHREAD_MUTEXATTR_GETTYPE(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_gettype, pthread_mutexattr_settype — get and set  the
13       mutex type attribute
14

SYNOPSIS

16       #include <pthread.h>
17
18       int pthread_mutexattr_gettype(const pthread_mutexattr_t *restrict attr,
19           int *restrict type);
20       int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type);
21

DESCRIPTION

23       The  pthread_mutexattr_gettype()  and pthread_mutexattr_settype() func‐
24       tions, respectively, shall get and set the mutex type  attribute.  This
25       attribute  is set in the type parameter to these functions. The default
26       value of the type attribute is PTHREAD_MUTEX_DEFAULT.
27
28       The type of mutex is contained in  the  type  attribute  of  the  mutex
29       attributes. Valid mutex types include:
30
31              PTHREAD_MUTEX_NORMAL                    PTHREAD_MUTEX_ERRORCHECK
32              PTHREAD_MUTEX_RECURSIVE PTHREAD_MUTEX_DEFAULT
33
34       The mutex type affects the behavior of calls which lock and unlock  the
35       mutex.  See pthread_mutex_lock() for details. An implementation may map
36       PTHREAD_MUTEX_DEFAULT to one of the other mutex types.
37
38       The behavior is undefined if the value specified by the  attr  argument
39       to  pthread_mutexattr_gettype() or pthread_mutexattr_settype() does not
40       refer to an initialized mutex attributes object.
41

RETURN VALUE

43       Upon successful completion,  the  pthread_mutexattr_gettype()  function
44       shall  return  zero  and  store the value of the type attribute of attr
45       into the object referenced by the type parameter. Otherwise,  an  error
46       shall be returned to indicate the error.
47
48       If  successful,  the  pthread_mutexattr_settype() function shall return
49       zero; otherwise, an error number shall  be  returned  to  indicate  the
50       error.
51

ERRORS

53       The pthread_mutexattr_settype() function shall fail if:
54
55       EINVAL The value type is invalid.
56
57       These functions shall not return an error code of [EINTR].
58
59       The following sections are informative.
60

EXAMPLES

62       None.
63

APPLICATION USAGE

65       It is advised that an application should not use a PTHREAD_MUTEX_RECUR‐
66       SIVE mutex with condition variables because the  implicit  unlock  per‐
67       formed  for  a  pthread_cond_timedwait() or pthread_cond_wait() may not
68       actually release the mutex (if it had been locked multiple  times).  If
69       this  happens,  no other thread can satisfy the condition of the predi‐
70       cate.
71

RATIONALE

73       If an implementation detects that the value specified by the attr argu‐
74       ment to pthread_mutexattr_gettype() or pthread_mutexattr_settype() does
75       not refer to an initialized mutex attributes object, it is  recommended
76       that the function should fail and report an [EINVAL] error.
77

FUTURE DIRECTIONS

79       None.
80

SEE ALSO

82       pthread_cond_timedwait(), pthread_mutex_lock()
83
84       The Base Definitions volume of POSIX.1‐2017, <pthread.h>
85
87       Portions  of  this text are reprinted and reproduced in electronic form
88       from IEEE Std 1003.1-2017, Standard for Information Technology --  Por‐
89       table  Operating System Interface (POSIX), The Open Group Base Specifi‐
90       cations Issue 7, 2018 Edition, Copyright (C) 2018 by the  Institute  of
91       Electrical  and  Electronics Engineers, Inc and The Open Group.  In the
92       event of any discrepancy between this version and the original IEEE and
93       The  Open Group Standard, the original IEEE and The Open Group Standard
94       is the referee document. The original Standard can be  obtained  online
95       at http://www.opengroup.org/unix/online.html .
96
97       Any  typographical  or  formatting  errors that appear in this page are
98       most likely to have been introduced during the conversion of the source
99       files  to  man page format. To report such errors, see https://www.ker
100       nel.org/doc/man-pages/reporting_bugs.html .
101
102
103
104IEEE/The Open Group                  2017        PTHREAD_MUTEXATTR_GETTYPE(3P)
Impressum