Loading...
Searching...
No Matches
pthread_mutex.h File Reference

Mutual exclusion. More...

Detailed Description

Mutual exclusion.

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

Definition in file pthread_mutex.h.

#include <time.h>
#include "mutex.h"
+ Include dependency graph for pthread_mutex.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

typedef mutex_t pthread_mutex_t
 Pthread mutexes are quite the same as RIOT mutexes.
 
int pthread_mutex_init (pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexattr)
 Initialize a mutex.
 
int pthread_mutex_destroy (pthread_mutex_t *mutex)
 Destroy a mutex.
 
int pthread_mutex_trylock (pthread_mutex_t *mutex)
 Try to lock a mutex.
 
int pthread_mutex_lock (pthread_mutex_t *mutex)
 Lock and hold a mutex.
 
int pthread_mutex_timedlock (pthread_mutex_t *mutex, const struct timespec *abstime)
 Not implemented, yet.
 
int pthread_mutex_unlock (pthread_mutex_t *mutex)
 Unlock a mutex.
 
int pthread_mutex_getprioceiling (const pthread_mutex_t *mutex, int *prioceiling)
 Not implemented, yet.
 
int pthread_mutex_setprioceiling (pthread_mutex_t *mutex, int prioceiling, int *old_ceiling)
 Not implemented, yet.
 

Typedef Documentation

◆ pthread_mutex_t

Pthread mutexes are quite the same as RIOT mutexes.

Recursive locking is not supported. A thread can unlock a mutex even if it does not hold it.

Definition at line 33 of file pthread_mutex.h.

Function Documentation

◆ pthread_mutex_destroy()

int pthread_mutex_destroy ( pthread_mutex_t mutex)

Destroy a mutex.

This is currently a no-op. Destroying a mutex locked is undefined behavior.

Parameters
[in,out]mutexDatum to destroy.
Returns
0, this invocation is a no-op that cannot fail.

◆ pthread_mutex_getprioceiling()

int pthread_mutex_getprioceiling ( const pthread_mutex_t mutex,
int *  prioceiling 
)

Not implemented, yet.

Will cause a linktime error ...

Parameters
[in]mutexThe unused mutex.
[out]prioceilingUnused.
Returns
Well ... you'll get a link time error, so nothing will be returned.

◆ pthread_mutex_init()

int pthread_mutex_init ( pthread_mutex_t mutex,
const pthread_mutexattr_t mutexattr 
)

Initialize a mutex.

A zeroed out datum is initialized.

Parameters
[in,out]mutexMutex to initialize.
[in]mutexattrUnused.
Returns
0 on success. -1 iff mutex == NULL.

◆ pthread_mutex_lock()

int pthread_mutex_lock ( pthread_mutex_t mutex)

Lock and hold a mutex.

This invocation may block if the mutex was locked.

Parameters
[in]mutexMutex to lock, must be initialized.
Returns
-1 iff you managed to supply NULL. 0 otherwise, you hold the mutex now.

◆ pthread_mutex_setprioceiling()

int pthread_mutex_setprioceiling ( pthread_mutex_t mutex,
int  prioceiling,
int *  old_ceiling 
)

Not implemented, yet.

Will cause a linktime error ...

Parameters
[in,out]mutexThe unused mutex.
[in]prioceilingUnused.
[out]old_ceilingUnused.
Returns
Well ... you'll get a link time error, so nothing will be returned.

◆ pthread_mutex_timedlock()

int pthread_mutex_timedlock ( pthread_mutex_t mutex,
const struct timespec *  abstime 
)

Not implemented, yet.

Will cause a linktime error ...

Parameters
[in]mutexThe unused mutex.
[in]abstimeThe used absolute time.
Returns
Well ... you'll get a link time error, so nothing will be returned.

◆ pthread_mutex_trylock()

int pthread_mutex_trylock ( pthread_mutex_t mutex)

Try to lock a mutex.

This function won't block.

Parameters
[in]mutexMutex to lock, must be initialized.
Returns
0 if you hold the mutex now. +1 if the mutex already was locked. -1 if you managed to supply NULL.

◆ pthread_mutex_unlock()

int pthread_mutex_unlock ( pthread_mutex_t mutex)

Unlock a mutex.

It is possible to unlock a mutex that you don't hold. It is possible to unlock a mutex that is not held at all. The mutex can still be locked afterwards if there were threads queuing for this mutex.

Parameters
[in]mutexMutex to unlock, must be initialized.
Returns
-1 iff you managed to supply NULL. 0 otherwise.