pthread_mutex_attr.h File Reference

Attributes for pthread mutexes. More...

Detailed Description

Attributes for pthread mutexes.

Note
Do not include this header file directly, but pthread.h.

Definition in file pthread_mutex_attr.h.

#include <errno.h>
+ Include dependency graph for pthread_mutex_attr.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  pthread_mutexattr_t
 This type is unused right now, and only exists for POSIX compatibility. More...
 
#define PTHREAD_MUTEX_NORMAL   0
 A non-error correcting mutex (default).
 
#define PTHREAD_MUTEX_RECURSIVE   1
 A mutex that allows recursive locking. More...
 
#define PTHREAD_MUTEX_ERRORCHECK   2
 A mutex that fails with EDEADLK if recursive locking was detected. More...
 
#define PTHREAD_MUTEX_DEFAULT   PTHREAD_MUTEX_NORMAL
 The default mutex kind for RIOT. More...
 
#define PTHREAD_PRIO_NONE   0
 No priority inheritance. More...
 
#define PTHREAD_PRIO_INHERIT   1
 If a thread attempts to acquire a held lock, the holding thread gets its dynamic priority increased up to the priority of the blocked thread. More...
 
#define PTHREAD_PRIO_PROTECT   2
 Not implemented, yet.
 
#define PTHREAD_MUTEX_STALLED   0
 Mutexes aren't automatically released on the end of a thread. More...
 
#define PTHREAD_MUTEX_ROBUST   1
 Mutexes that are held at the exit of a thread get released automatically. More...
 
int pthread_mutexattr_init (pthread_mutexattr_t *attr)
 Initialize a pthread_mutexattr_t. More...
 
int pthread_mutexattr_destroy (pthread_mutexattr_t *attr)
 Destroys a pthread_mutexattr_t. More...
 
int pthread_mutexattr_getpshared (const pthread_mutexattr_t *attr, int *pshared)
 Queries the attribute set whether to share the mutex with child processes. More...
 
int pthread_mutexattr_setpshared (pthread_mutexattr_t *attr, int pshared)
 Set whether to share the mutex with child processes. More...
 
int pthread_mutexattr_gettype (const pthread_mutexattr_t *attr, int *kind)
 Query the type of the mutex to create. More...
 
int pthread_mutexattr_settype (pthread_mutexattr_t *attr, int kind)
 Sets the type of the mutex to create. More...
 
int pthread_mutexattr_getprotocol (const pthread_mutexattr_t *attr, int *protocol)
 Query the priority inheritance of the mutex to create. More...
 
int pthread_mutexattr_setprotocol (pthread_mutexattr_t *attr, int protocol)
 Sets the priority inheritance of the mutex to create. More...
 
int pthread_mutexattr_getprioceiling (const pthread_mutexattr_t *attr, int *prioceiling)
 
int pthread_mutexattr_setprioceiling (pthread_mutexattr_t *attr, int prioceiling)
 
int pthread_mutexattr_getrobust (const pthread_mutexattr_t *attr, int *robustness)
 Query the attribute set whether to create a robut mutex. More...
 
int pthread_mutexattr_setrobust (pthread_mutexattr_t *attr, int robustness)
 Set whether the mutex to create should be robust. More...
 

Macro Definition Documentation

◆ PTHREAD_MUTEX_DEFAULT

#define PTHREAD_MUTEX_DEFAULT   PTHREAD_MUTEX_NORMAL

The default mutex kind for RIOT.

Note
Not implemented, yet.

Definition at line 48 of file pthread_mutex_attr.h.

◆ PTHREAD_MUTEX_ERRORCHECK

#define PTHREAD_MUTEX_ERRORCHECK   2

A mutex that fails with EDEADLK if recursive locking was detected.

Note
Not implemented, yet.

Definition at line 47 of file pthread_mutex_attr.h.

◆ PTHREAD_MUTEX_RECURSIVE

#define PTHREAD_MUTEX_RECURSIVE   1

A mutex that allows recursive locking.

Note
Not implemented, yet.

Definition at line 46 of file pthread_mutex_attr.h.

◆ PTHREAD_MUTEX_ROBUST

#define PTHREAD_MUTEX_ROBUST   1

Mutexes that are held at the exit of a thread get released automatically.

Note
Not implemented, yet.

Definition at line 83 of file pthread_mutex_attr.h.

◆ PTHREAD_MUTEX_STALLED

#define PTHREAD_MUTEX_STALLED   0

Mutexes aren't automatically released on the end of a thread.

See also
pthread_cleanup_push() for an option to unlock mutexes on the end of a thread.
Note
This is the default.

Definition at line 82 of file pthread_mutex_attr.h.

◆ PTHREAD_PRIO_INHERIT

#define PTHREAD_PRIO_INHERIT   1

If a thread attempts to acquire a held lock, the holding thread gets its dynamic priority increased up to the priority of the blocked thread.

Note
Not implemented, yet.

Definition at line 64 of file pthread_mutex_attr.h.

◆ PTHREAD_PRIO_NONE

#define PTHREAD_PRIO_NONE   0

No priority inheritance.

Prone to inversed priorities. The default mutex protocol.

Definition at line 63 of file pthread_mutex_attr.h.

Function Documentation

◆ pthread_mutexattr_destroy()

int pthread_mutexattr_destroy ( pthread_mutexattr_t attr)

Destroys a pthread_mutexattr_t.

There is no need to ever call this function. This function is a no-op.

Note
This function is not implemented, yet.
Parameters
[in,out]attrDatum to destroy.
Returns
0 on success. EINVAL if attr == NULL.

◆ pthread_mutexattr_getprotocol()

int pthread_mutexattr_getprotocol ( const pthread_mutexattr_t attr,
int *  protocol 
)

Query the priority inheritance of the mutex to create.

Note
This implementation only supports PTHREAD_PRIO_NONE mutexes.
Parameters
[in]attrAttribute set to query
[out]protocolEither PTHREAD_PRIO_NONE or PTHREAD_PRIO_INHERIT or PTHREAD_PRIO_PROTECT.
Returns
0 on success. EINVAL if attr or protocol are NULL.

◆ pthread_mutexattr_getpshared()

int pthread_mutexattr_getpshared ( const pthread_mutexattr_t attr,
int *  pshared 
)

Queries the attribute set whether to share the mutex with child processes.

Note
Since RIOT does not implement processes, this value is unused.
Parameters
[in]attrAttribute set to query.
[out]psharedEither PTHREAD_PROCESS_SHARED or PTHREAD_PROCESS_PRIVATE.
Returns
0 on success. EINVAL if attr or pshared are NULL.

◆ pthread_mutexattr_getrobust()

int pthread_mutexattr_getrobust ( const pthread_mutexattr_t attr,
int *  robustness 
)

Query the attribute set whether to create a robut mutex.

A "robust" mutex releases gets released automagically if the threads exits while it hold the mutex. If the thread is cancellable, only rubust mutex should be held.

Note
This implementation does not support robust mutexes, yet. As it doesn't implement cancellation points, yet, this should not pose a problem.
Parameters
[in]attrAttribute set to query.
[out]robustnessEither PTHREAD_MUTEX_STALLED or PTHREAD_MUTEX_ROBUST.
Returns
0 on success. EINVAL if the value of protocol is unsupported. EINVAL if attr or robustness is NULL.

◆ pthread_mutexattr_gettype()

int pthread_mutexattr_gettype ( const pthread_mutexattr_t attr,
int *  kind 
)

Query the type of the mutex to create.

Note
This implementation only supports PTHREAD_MUTEX_NORMAL mutexes.
Parameters
[in]attrAttribute set to query.
[out]kindEither PTHREAD_MUTEX_NORMAL or PTHREAD_MUTEX_RECURSIVE or PTHREAD_MUTEX_ERRORCHECK.
Returns
0 on success. EINVAL if attr or kind are NULL.

◆ pthread_mutexattr_init()

int pthread_mutexattr_init ( pthread_mutexattr_t attr)

Initialize a pthread_mutexattr_t.

A zeroed out datum is initialized

Note
This function is not implemented, yet.
Parameters
[out]attrDatum to initialize.
Returns
0 on success. EINVAL if attr == NULL.

◆ pthread_mutexattr_setprotocol()

int pthread_mutexattr_setprotocol ( pthread_mutexattr_t attr,
int  protocol 
)

Sets the priority inheritance of the mutex to create.

Note
This implementation only supports PTHREAD_PRIO_NONE mutexes.
Parameters
[in,out]attrAttribute set to change.
[in]protocolEither PTHREAD_PRIO_NONE or PTHREAD_PRIO_INHERIT or PTHREAD_PRIO_PROTECT.
Returns
0 on success. EINVAL if the value of protocol is unsupported. EINVAL if attr == NULL.

◆ pthread_mutexattr_setpshared()

int pthread_mutexattr_setpshared ( pthread_mutexattr_t attr,
int  pshared 
)

Set whether to share the mutex with child processes.

Note
Since RIOT does not implement processes, this value is unused.
Parameters
[in,out]attrAttribute set to change.
[in]psharedEither PTHREAD_PROCESS_SHARED or PTHREAD_PROCESS_PRIVATE.
Returns
0 on success. EINVAL if pshared is neither PTHREAD_PROCESS_SHARED nor PTHREAD_PROCESS_PRIVATE. EINVAL if attr == NULL.

◆ pthread_mutexattr_setrobust()

int pthread_mutexattr_setrobust ( pthread_mutexattr_t attr,
int  robustness 
)

Set whether the mutex to create should be robust.

A "robust" mutex releases gets released automagically if the threads exits while it hold the mutex. If the thread is cancellable, only rubust mutex should be held.

Note
This implementation does not support robust mutexes, yet. As it doesn't implement cancellation points, yet, this should not pose a problem.
Parameters
[in,out]attrAttribute set to change.
[in]robustnessEither PTHREAD_MUTEX_STALLED or PTHREAD_MUTEX_ROBUST.
Returns
0 on success. EINVAL if the value of robustness is unsupported. EINVAL if attr == NULL.

◆ pthread_mutexattr_settype()

int pthread_mutexattr_settype ( pthread_mutexattr_t attr,
int  kind 
)

Sets the type of the mutex to create.

Note
This implementation only supports PTHREAD_MUTEX_NORMAL mutexes.
Parameters
[in,out]attrAttribute set to change.
[in]kindEither PTHREAD_MUTEX_NORMAL or PTHREAD_MUTEX_RECURSIVE or PTHREAD_MUTEX_ERRORCHECK.
Returns
0 on success. EINVAL if the value of kind is unsupported. EINVAL if attr == NULL.