code wiki / (root) / nx_mutex_race_test.nx

nx_mutex_race_test.nx

buildroot/runtime/nx_mutex_race_test.nx

2761 B78 linesdepth 6pulls 13 transitivereach 0 importersview sourcekind gate/proof
docsdependenciesstructsconstsfunctions

about

nx_mutex_race_test.nx -- prove the mutex provides REAL mutual exclusion under multi-thread contention. hw-derived (cpu_count * STRESS_FACTOR) worker threads each grab the same mutex N times and bump a PLAIN (non-atomic) counter inside the critical section. If the mutex doesn't actually exclude, the non-atomic increment races and final counter < N (lost updates). PASS criterion: final counter == n_threads * N exactly.

dependencies 6 imports · 0 importers

nx_kernel_v2.nx nx_log.nx nx_atom.nx nx_thread.nx nx_mutex.nx nx_hw.nx nx_mutex_race_test.nx

imports: nx_kernel_v2.nxnx_log.nxnx_atom.nxnx_thread.nxnx_mutex.nxnx_hw.nx

imported by: nobody (leaf or entry point)

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

main nx_hw_worker_count nx_hw_cpu_count sys_mmap sys_munmap nx_thread_spawn_fn sys_mmap ↻ nx_atom_load_i64

structs

21struct SharedCounter

consts

18const ITERATIONS_PER_THREAD: i64 = 5000
19const STRESS_FACTOR: i64 = 4

functions

27func worker_lock_bump(arg: *u8) -> i64
44func main() -> nx_exit