pthread_mutex_attr.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 Freie Universität Berlin
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
9 #pragma once
10 
19 #include <errno.h>
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
44 #define PTHREAD_MUTEX_NORMAL 0
45 #define PTHREAD_MUTEX_RECURSIVE 1
46 #define PTHREAD_MUTEX_ERRORCHECK 2
47 #define PTHREAD_MUTEX_DEFAULT PTHREAD_MUTEX_NORMAL
48 
62 #define PTHREAD_PRIO_NONE 0
63 #define PTHREAD_PRIO_INHERIT 1
64 
80 #define PTHREAD_PRIO_PROTECT 2
81 #define PTHREAD_MUTEX_STALLED 0
82 #define PTHREAD_MUTEX_ROBUST 1
83 
87 typedef struct
88 {
89  int pshared;
90  int kind;
91  int protocol;
92  int robustness;
94 
104 
115 
124 int pthread_mutexattr_getpshared(const pthread_mutexattr_t *attr, int *pshared);
125 
136 
145 int pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, int *kind);
146 
157 
166 int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *attr, int *protocol);
167 
178 
179 /* Return in *PRIOCEILING the mutex prioceiling attribute in *ATTR. */
180 int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t *attr, int *prioceiling);
181 
182 /* Set the mutex prioceiling attribute in *ATTR to PRIOCEILING. */
183 int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *attr, int prioceiling);
184 
197 int pthread_mutexattr_getrobust(const pthread_mutexattr_t *attr, int *robustness);
198 
212 
213 #ifdef __cplusplus
214 }
215 #endif
216 
int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *attr, int *protocol)
Query the priority inheritance of the mutex to create.
int pthread_mutexattr_destroy(pthread_mutexattr_t *attr)
Destroys a pthread_mutexattr_t.
int pthread_mutexattr_getrobust(const pthread_mutexattr_t *attr, int *robustness)
Query the attribute set whether to create a robut mutex.
int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int kind)
Sets the type of the mutex to create.
int pthread_mutexattr_setpshared(pthread_mutexattr_t *attr, int pshared)
Set whether to share the mutex with child processes.
int pthread_mutexattr_setrobust(pthread_mutexattr_t *attr, int robustness)
Set whether the mutex to create should be robust.
int pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, int *kind)
Query the type of the mutex to create.
int pthread_mutexattr_setprotocol(pthread_mutexattr_t *attr, int protocol)
Sets the priority inheritance of the mutex to create.
int pthread_mutexattr_getpshared(const pthread_mutexattr_t *attr, int *pshared)
Queries the attribute set whether to share the mutex with child processes.
int pthread_mutexattr_init(pthread_mutexattr_t *attr)
Initialize a pthread_mutexattr_t.
This type is unused right now, and only exists for POSIX compatibility.
int kind
Type of the mutex.
int protocol
Priority inheritance of the mutex.
int pshared
Whether to share the mutex with child processes.
int robustness
What to do if a thread terminates while it holds a mutex.