rmutex.h¶
Recursive Mutex for thread synchronization.
RIOT synchronization API
-
RMUTEX_INIT
¶ Static initializer for rmutex_t.
1
{ MUTEX_INIT, 0, ATOMIC_VAR_INIT(KERNEL_PID_UNDEF) }
This initializer is preferable to
rmutex.h::rmutex_init()
.
-
struct rmutex_t
rmutex_t
¶ Mutex structure.
Must never be modified by the user.
-
void
rmutex_init
(rmutex_t * rmutex)¶ Initializes a recursive mutex object.
For initialization of variables use RMUTEX_INIT instead. Only use the function call for dynamically allocated mutexes.
Parameters
rmutex: pre-allocated mutex structure, must not be NULL.
-
int
rmutex_trylock
(rmutex_t * rmutex)¶ Tries to get a recursive mutex, non-blocking.
Parameters
rmutex: Recursive mutex object to lock. Has to be initialized first. Must not be NULL. Return values
- 1 if mutex was unlocked, now it is locked.
- 0 if the mutex was locked.
-
void
rmutex_lock
(rmutex_t * rmutex)¶ Locks a recursive mutex, blocking.
Parameters
rmutex: Recursive mutex object to lock. Has to be initialized first. Must not be NULL.
-
void
rmutex_unlock
(rmutex_t * rmutex)¶ Unlocks the recursive mutex.
Parameters
rmutex: Recursive mutex object to unlock, must not be NULL.
-
struct
rmutex_t
¶ Mutex structure.
Must never be modified by the user.
-
uint16_t
refcount
¶ Number of locks owned by the thread owner.
-
atomic_int_least16_t
owner
¶ Owner thread of the mutex.
Owner is written by the mutex holder, and read concurrently to ensure consistency, atomic_int_least16_t is used. Note
kernel_types.h::kernel_pid_t
is an int16
-
uint16_t