nx_chan_mpmc_test.nx
buildroot/runtime/nx_chan_mpmc_test.nx
about
nx_chan_mpmc_test.nx -- prove Vyukov MPMC channel under real
multi-producer + multi-consumer contention.
Test design:
- hw_workers producer threads, each sends ITERATIONS_PER_PRODUCER
messages (just their thread index repeated -- value content
irrelevant; we count receipts).
- hw_workers consumer threads, each drains until total received
atomic counter hits expected total.
- Atomic done-counter signals when all producers have finished
pushing, so consumers know when to stop spinning on empty.
PASS criteria:
- total_received == producers * ITERATIONS_PER_PRODUCER (no lost
messages, no duplicates)
- chan_len returns 0 at end (queue drained)
If Vyukov MPMC is broken (CAS race exposes wrong cell, ABA-style
re-use), we'll see lost or duplicated messages -> total mismatch.
dependencies 6 imports · 0 importers
imports: nx_kernel_v2.nxnx_log.nxnx_atom.nxnx_thread.nxnx_chan.nxnx_hw.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| 32 | struct McShared |
consts
| 28 | const ITERATIONS_PER_PRODUCER: i64 = 2000 |
| 29 | const STRESS_FACTOR: i64 = 4 |
functions
| 40 | func producer_main(arg: *u8) -> i64 |
| 54 | func consumer_main(arg: *u8) -> i64 |
| 85 | func main() -> nx_exit |