pthread_mutex_attr.h

Attributes for pthread mutexes.

Note

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

PTHREAD_MUTEX_NORMAL

A non-error correcting mutex (default).

1
0
PTHREAD_MUTEX_RECURSIVE

A mutex that allows recursive locking.

1
1

Note

Not implemented, yet.

PTHREAD_MUTEX_ERRORCHECK

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

1
2

Note

Not implemented, yet.

PTHREAD_MUTEX_DEFAULT

The default mutex kind for RIOT.

1
PTHREAD_MUTEX_NORMAL

Note

Not implemented, yet.

PTHREAD_PRIO_NONE

No priority inheritance.

1
0

Prone to inversed priorities. The default mutex protocol.

PTHREAD_PRIO_INHERIT

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.

1
1

Note

Not implemented, yet.

PTHREAD_PRIO_PROTECT

Not implemented, yet.

1
2
PTHREAD_MUTEX_STALLED

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

1
0

See also

pthread_cleanup.h::pthread_cleanup_push for an option to unlock mutexes on the end of a thread.

Note

This is the default.

PTHREAD_MUTEX_ROBUST

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

1
1

Note

Not implemented, yet.

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

attr:Datum to initialize.

Return values

  • 0 on success. EINVAL if attr == NULL.
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

attr:Datum to destroy.

Return values

  • 0 on success. EINVAL if attr == NULL.
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

attr:Attribute set to query.
pshared:Either pthread_barrier.h::PTHREAD_PROCESS_SHARED or pthread_barrier.h::PTHREAD_PROCESS_PRIVATE.

Return values

  • 0 on success. EINVAL if attr or pshared are NULL.
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

attr:Attribute set to change.
pshared:Either pthread_barrier.h::PTHREAD_PROCESS_SHARED or pthread_barrier.h::PTHREAD_PROCESS_PRIVATE.

Return values

  • 0 on success. EINVAL if pshared is neither pthread_barrier.h::PTHREAD_PROCESS_SHARED nor pthread_barrier.h::PTHREAD_PROCESS_PRIVATE. EINVAL if attr == NULL.
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

attr:Attribute set to query.
kind:Either pthread_mutex_attr.h::PTHREAD_MUTEX_NORMAL or pthread_mutex_attr.h::PTHREAD_MUTEX_RECURSIVE or pthread_mutex_attr.h::PTHREAD_MUTEX_ERRORCHECK.

Return values

  • 0 on success. EINVAL if attr or kind are NULL.
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

attr:Attribute set to change.
kind:Either pthread_mutex_attr.h::PTHREAD_MUTEX_NORMAL or pthread_mutex_attr.h::PTHREAD_MUTEX_RECURSIVE or pthread_mutex_attr.h::PTHREAD_MUTEX_ERRORCHECK.

Return values

  • 0 on success. EINVAL if the value of kind is unsupported. EINVAL if attr == NULL.
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

attr:Attribute set to query
protocol:Either pthread_mutex_attr.h::PTHREAD_PRIO_NONE or pthread_mutex_attr.h::PTHREAD_PRIO_INHERIT or pthread_mutex_attr.h::PTHREAD_PRIO_PROTECT.

Return values

  • 0 on success. EINVAL if attr or protocol are NULL.
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

attr:Attribute set to change.
protocol:Either pthread_mutex_attr.h::PTHREAD_PRIO_NONE or pthread_mutex_attr.h::PTHREAD_PRIO_INHERIT or pthread_mutex_attr.h::PTHREAD_PRIO_PROTECT.

Return values

  • 0 on success. EINVAL if the value of protocol is unsupported. EINVAL if attr == NULL.
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.

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

attr:Attribute set to query.
robustness:Either pthread_mutex_attr.h::PTHREAD_MUTEX_STALLED or pthread_mutex_attr.h::PTHREAD_MUTEX_ROBUST.

Return values

  • 0 on success. EINVAL if the value of protocol is unsupported. EINVAL if attr or robustness is NULL.
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

attr:Attribute set to change.
robustness:Either pthread_mutex_attr.h::PTHREAD_MUTEX_STALLED or pthread_mutex_attr.h::PTHREAD_MUTEX_ROBUST.

Return values

  • 0 on success. EINVAL if the value of robustness is unsupported. EINVAL if attr == NULL.
struct pthread_mutexattr_t

This type is unused right now, and only exists for POSIX compatibility.

int pshared

Whether to share the mutex with child processes.

int kind

Type of the mutex.

int protocol

Priority inheritance of the mutex.

int robustness

What to do if a thread terminates while it holds a mutex.