Contiki-NG
|
Macros | |
#define | mutex_try_lock(m) mutex_generic_try_lock(m) |
Try to lock a mutex. | |
#define | mutex_unlock(m) mutex_generic_unlock(m) |
Unlock a previously acquired mutex. | |
Typedefs | |
typedef uint_fast8_t | mutex_t |
Mutex data type. | |
Functions | |
bool | mutex_generic_try_lock (volatile mutex_t *mutex) |
Try to lock a mutex. | |
void | mutex_generic_unlock (volatile mutex_t *mutex) |
Unlock a previously acquired mutex. | |
This library provides an API and generic implementation of mutexes.
Calling code should manipulate mutexes through the mutex_try_lock() and mutex_unlock() macros. By default, those macros will expand to the generic mutex manipulation implementations provided here. While these will work, they do reply on disabling the master interrupt in order to perform the lock/unlock operation.
It is possible to override those generic implementation with CPU-specific implementations that exploit synchronisation instructions. To do so, create a CPU-specific header file. In this file, define mutex_try_lock() and mutex_unlock() to expand to the respective CPU function names. These can (but do not have to) be inlined. Then define MUTEX_CONF_ARCH_HEADER_PATH as this header's filename.
#define mutex_try_lock | ( | m | ) | mutex_generic_try_lock(m) |
Try to lock a mutex.
m | A pointer to the mutex to be locked |
true | Locking succeeded |
false | Locking failed (the mutex is already locked) |
This macro will expand to mutex_generic_try_lock() or to a CPU-provided implementation. Platform-independent code should use this macro instead of mutex_generic_try_lock().
#define mutex_unlock | ( | m | ) | mutex_generic_unlock(m) |
Unlock a previously acquired mutex.
m | A pointer to the mutex to be unlocked |
This macro will expand to mutex_generic_unlock() or to a CPU-provided implementation. Platform-independent code should use this macro instead of mutex_generic_unlock().
typedef uint_fast8_t mutex_t |
bool mutex_generic_try_lock | ( | volatile mutex_t * | mutex | ) |
Try to lock a mutex.
mutex | A pointer to the mutex to be locked |
true | Locking succeeded |
false | Locking failed (the mutex is already locked) |
Do not call this function directly. Use the mutex_try_lock() macro instead.
Definition at line 45 of file mutex.c.
References critical_enter(), and critical_exit().
void mutex_generic_unlock | ( | volatile mutex_t * | mutex | ) |
Unlock a previously acquired mutex.
mutex | A pointer to the mutex to be unlocked |
Do not call this function directly. Use the mutex_unlock() macro instead.
Definition at line 61 of file mutex.c.
References critical_enter(), and critical_exit().