Mutexes / Futexes
CMRX offers mutual exclusive access facilities for userspace processes. There is an implementation of futex (fast userspace mutex) available and supported. There is also an implementation of mutex (driven by kernel), but this might get deprecated anytime soon.
Function-like Macros
int futex_init(futex_t *restrict futex)
Advantage of futex over mutex is, that it can be locked and unlocked completely from userspace. Futexes can be shared safely between threads of single process, yet can’t be normally shared between threads of multiple processes unless explicitly placed into shared memory region.
Type Definitons
typedef futex_t mutex_t
Functions
int futex_destroy(futex_t *futex)
int futex_lock(futex_t *futex)
int futex_unlock(futex_t *futex)
int futex_trylock(futex_t *futex)
Macros
MUTEX_INITIALIZED
FUTEX_STATIC_INIT
If futex is initialized using this value, then it is not necessary to call futex_init()