code wiki / (root) / nx_cond.nx

nx_cond.nx

buildroot/runtime/nx_cond.nx

3111 B97 linesdepth 4pulls 5 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_cond.nx -- condition variable on top of nx_mutex + futex. Condition variables let a thread block until another thread signals "the condition you were waiting on is now true". The classic producer/consumer pattern: producer: consumer: mutex.lock mutex.lock queue.push(item) while queue.empty: cond.signal cond.wait(mutex) # atomic unlock+sleep mutex.unlock item = queue.pop mutex.unlock Implementation uses Linux futex with a sequence counter. Each nx_cond_wait reads the current seq, drops the mutex, blocks on futex(seq), then reacquires the mutex on wakeup. signal/broadcast bump seq + futex_wake. Pairs with nx_mutex (the lock you must hold when calling wait / signal) + nx_atom (eventual SMP correctness).

dependencies 2 imports · 0 importers

syscalls.nx nx_mutex.nx nx_cond.nx

imports: syscalls.nxnx_mutex.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main nx_cond_new nx_cond_signal nx_cond_broadcast

structs

37struct NxCond

consts

31const NX_SYS_FUTEX_2: i64 = 98
33const NX_FUTEX_WAIT_2: i64 = 0
34const NX_FUTEX_WAKE_2: i64 = 1
35const NX_FUTEX_PRIVATE_2: i64 = 128
41const NX_COND_BYTES: i64 = 8

functions

43func nx_cond_new() -> *NxCond
called by 1: main
52func nx_cond_wait(c: *NxCond, m: *NxMutex) -> i64
64func nx_cond_signal(c: *NxCond) -> i64
called by 1: main
71func nx_cond_broadcast(c: *NxCond) -> i64
called by 1: main
79func main() -> i64