Loading...
Searching...
No Matches
Recursive Mutex

Recursive Mutex for thread synchronization. More...

Detailed Description

Recursive Mutex for thread synchronization.

Files

file  rmutex.h
 Recursive Mutex for thread synchronization.
 

Data Structures

struct  rmutex_t
 Mutex structure. More...
 

Macros

#define RMUTEX_INIT   { MUTEX_INIT, 0, KERNEL_PID_UNDEF }
 Static initializer for rmutex_t.
 

Typedefs

typedef struct rmutex_t rmutex_t
 Mutex structure.
 

Functions

static void rmutex_init (rmutex_t *rmutex)
 Initializes a recursive mutex object.
 
int rmutex_trylock (rmutex_t *rmutex)
 Tries to get a recursive mutex, non-blocking.
 
void rmutex_lock (rmutex_t *rmutex)
 Locks a recursive mutex, blocking.
 
int rmutex_trylock_max (rmutex_t *rmutex, uint16_t max)
 Tries to get a recursive mutex without exceeding a maximum recursion depth, non-blocking.
 
int rmutex_lock_max (rmutex_t *rmutex, uint16_t max)
 Tries to get a recursive mutex without exceeding a maximum recursion depth, blocking.
 
void rmutex_unlock (rmutex_t *rmutex)
 Unlocks the recursive mutex.
 

Macro Definition Documentation

◆ RMUTEX_INIT

#define RMUTEX_INIT   { MUTEX_INIT, 0, KERNEL_PID_UNDEF }

Static initializer for rmutex_t.

This initializer is preferable to rmutex_init().

Definition at line 63 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 71 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_lock_max()

int rmutex_lock_max ( rmutex_t * rmutex,
uint16_t max )

Tries to get a recursive mutex without exceeding a maximum recursion depth, blocking.

Parameters
[in]rmutexRecursive mutex object to lock. Has to be initialized first. Must not be NULL.
[in]maxmaximum recursion depth.
Return values
1if the mutex was unlocked, now it is locked.
0if recursion depth was exceeded.

◆ 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.
Return values
1if the mutex was unlocked or locked by same thread, it is locked now.
0if the mutex was locked by another thread.

◆ rmutex_trylock_max()

int rmutex_trylock_max ( rmutex_t * rmutex,
uint16_t max )

Tries to get a recursive mutex without exceeding a maximum recursion depth, non-blocking.

Parameters
[in]rmutexRecursive mutex object to lock. Has to be initialized first. Must not be NULL.
[in]maxmaximum recursion depth, must be > 0.
Return values
1if the mutex was unlocked, now it is locked.
0if the mutex was locked or the recursion depth has been exceeded.

◆ rmutex_unlock()

void rmutex_unlock ( rmutex_t * rmutex)

Unlocks the recursive mutex.

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