The friendly Operating System for the Internet of Things
Synchronization

Mutex for thread synchronization. More...

Detailed Description

Files

file  mutex.h
 RIOT synchronization API.
 
file  rmutex.h
 Recursive Mutex for thread synchronization.
 

Data Structures

struct  mutex_t
 Mutex structure. More...
 

Macros

#define MUTEX_INIT   { { NULL } }
 Static initializer for mutex_t. More...
 
#define MUTEX_INIT_LOCKED   { { MUTEX_LOCKED } }
 Static initializer for mutex_t with a locked mutex.
 

Functions

static void mutex_init (mutex_t *mutex)
 Initializes a mutex object. More...
 
int _mutex_lock (mutex_t *mutex, int blocking)
 Lock a mutex, blocking or non-blocking. More...
 
static int mutex_trylock (mutex_t *mutex)
 Tries to get a mutex, non-blocking. More...
 
static void mutex_lock (mutex_t *mutex)
 Locks a mutex, blocking. More...
 
void mutex_unlock (mutex_t *mutex)
 Unlocks the mutex. More...
 
void mutex_unlock_and_sleep (mutex_t *mutex)
 Unlocks the mutex and sends the current thread to sleep. More...
 

Macro Definition Documentation

#define MUTEX_INIT   { { NULL } }

This initializer is preferable to mutex_init().

Definition at line 49 of file mutex.h.

Function Documentation

int _mutex_lock ( mutex_t mutex,
int  blocking 
)

For commit purposes you should probably use mutex_trylock() and mutex_lock() instead.

Parameters
[in]mutexMutex object to lock. Has to be initialized first. Must not be NULL.
[in]blockingif true, block until mutex is available.
Returns
1 if mutex was unlocked, now it is locked.
0 if the mutex was locked.
static void mutex_init ( mutex_t mutex)
inlinestatic

For initialization of variables use MUTEX_INIT instead. Only use the function call for dynamically allocated mutexes.

Parameters
[out]mutexpre-allocated mutex structure, must not be NULL.

Definition at line 72 of file mutex.h.

static void mutex_lock ( mutex_t mutex)
inlinestatic
Parameters
[in]mutexMutex object to lock. Has to be initialized first. Must not be NULL.

Definition at line 111 of file mutex.h.

static int mutex_trylock ( mutex_t mutex)
inlinestatic
Parameters
[in]mutexMutex object to lock. Has to be initialized first. Must not be NULL.
Returns
1 if mutex was unlocked, now it is locked.
0 if the mutex was locked.

Definition at line 101 of file mutex.h.

void mutex_unlock ( mutex_t mutex)
Parameters
[in]mutexMutex object to unlock, must not be NULL.
void mutex_unlock_and_sleep ( mutex_t mutex)
Parameters
[in]mutexMutex object to unlock, must not be NULL.