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
11

NAME

13       pthread_mutexattr_gettype, pthread_mutexattr_settype — get and set  the
14       mutex type attribute
15

SYNOPSIS

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

DESCRIPTION

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

RETURN VALUE

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

ERRORS

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

EXAMPLES

63       None.
64

APPLICATION USAGE

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

RATIONALE

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

FUTURE DIRECTIONS

80       None.
81

SEE ALSO

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