Go to the documentation of this file.
72 bool p00_cm_islocked(
unsigned p00_act) {
77 bool p00_cm_isntlocked(
unsigned p00_act) {
108 # define P99_CM_INITIALIZER P99_FUTEX_INITIALIZER(p99_cm_unlocked)
110 enum { p00_cm_unlocked, p00_cm_locked, };
116 void p00_cm_signal(
p99_cm volatile* p00_cm) {
130 void p00_cm_unlock(
p99_cm volatile* p00_cm) {
147 p00_cm_signal(p00_cm);
148 p00_cm_unlock(p00_cm);
165 p00_act == p00_cm_unlocked,
192 p00_cm_unlock(p00_cm);
213 #define P99_CM_EXCLUDE(CMP) P00_CM_EXCLUDE(CMP, P99_UNIQ(cm))
215 #define P00_CM_EXCLUDE(CMP, ID) \
217 P00_BLK_DECL(register p99_cm volatile*const, ID, (CMP)) \
218 P00_BLK_BEFAFT(p99_cm_lock(ID), \
void p99_cm_lock(p99_cm volatile *p00_cm)
Acquire p00_cm.
void p99_futex_destroy(p99_futex *p00_c)
Destroy an p99_futex object.
A counter similar to a conditional variable that allows atomic increment and decrement and to wait fo...
struct p99_cm p99_cm
A simple condition-mutex data structure.
void p99_cm_destroy(p99_cm *p00_cm)
destroy a cm
unsigned p99_futex_exchange(p99_futex volatile *p00_fut, unsigned p00_desired, unsigned p00_cstart, unsigned p00_clen, unsigned p00_wmin, unsigned p00_wmax)
Unconditionally and atomically set the futex p00_fut to value p00_desired.
void p99_cm_unlock(p99_cm volatile *p00_cm)
Unconditionally unlock p00_cm and wake up a waiter, if any.
#define p99_inline
Try to force a function always to be inlined.
void p99_cm_wait(p99_cm volatile *p00_cm)
Wait until another thread successfully locks and unlocks p00_cm.
#define P99_FUTEX_COMPARE_EXCHANGE(FUTEX, ACT, EXPECTED, DESIRED, WAKEMIN, WAKEMAX)
a catch all macro to operate on p99_futex
#define P99_DECLARE_STRUCT(NAME)
forward declaration of a struct NAME
void p99_futex_wakeup(p99_futex volatile *p00_fut, unsigned p00_wmin, unsigned p00_wmax)
Wake up threads that are waiting for a futex.
void p99_futex_wait(p99_futex volatile *p00_fut)
Unconditionally wait for futex p00_fut.
p99_cm * p99_cm_init(p99_cm *p00_cm)
Initialize a cm.
bool p99_cm_trylock(p99_cm volatile *p00_cm)
Acquire p00_cm.
p99_futex * p99_futex_init(p99_futex *p00_c, unsigned p00_ini)
Initialize an p99_futex object.