rmutex.h File Reference

Recursive Mutex for thread synchronization. More...

Detailed Description

Recursive Mutex for thread synchronization.

RIOT synchronization API

Author
Martin Elshuber marti.nosp@m.n.el.nosp@m.shube.nosp@m.r@th.nosp@m.eobro.nosp@m.ma-s.nosp@m.ystem.nosp@m.s.co.nosp@m.m

Definition in file rmutex.h.

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

Go to the source code of this file.

Data Structures

struct  rmutex_t
 Mutex structure. More...
 
#define RMUTEX_INIT   { MUTEX_INIT, 0, ATOMIC_VAR_INIT(KERNEL_PID_UNDEF) }
 Static initializer for rmutex_t. More...
 
typedef struct rmutex_t rmutex_t
 Mutex structure. More...
 
static void rmutex_init (rmutex_t *rmutex)
 Initializes a recursive mutex object. More...
 
int rmutex_trylock (rmutex_t *rmutex)
 Tries to get a recursive mutex, non-blocking. More...
 
void rmutex_lock (rmutex_t *rmutex)
 Locks a recursive mutex, blocking. More...
 
void rmutex_unlock (rmutex_t *rmutex)
 Unlocks the recursive mutex. More...
 

Macro Definition Documentation

◆ RMUTEX_INIT

#define RMUTEX_INIT   { MUTEX_INIT, 0, ATOMIC_VAR_INIT(KERNEL_PID_UNDEF) }

Static initializer for rmutex_t.

This initializer is preferable to rmutex_init().

Definition at line 65 of file rmutex.h.

Typedef Documentation

◆ rmutex_t

typedef struct rmutex_t rmutex_t

Mutex structure.

Must never be modified by the user.

Function Documentation

◆ rmutex_init()

static void rmutex_init ( rmutex_t rmutex)
inlinestatic

Initializes a recursive mutex object.

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

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

Definition at line 73 of file rmutex.h.

◆ rmutex_lock()

void rmutex_lock ( rmutex_t rmutex)

Locks a recursive mutex, blocking.

Parameters
[in]rmutexRecursive mutex object to lock. Has to be initialized first. Must not be NULL.

◆ rmutex_trylock()

int rmutex_trylock ( rmutex_t rmutex)

Tries to get a recursive mutex, non-blocking.

Parameters
[in]rmutexRecursive mutex 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.

◆ rmutex_unlock()

void rmutex_unlock ( rmutex_t rmutex)

Unlocks the recursive mutex.

Parameters
[in]rmutexRecursive mutex object to unlock, must not be NULL.