nx_resource_arbiter.nx
buildroot/runtime/nx_resource_arbiter.nx
about
nx_resource_arbiter.nx -- allocation under contention with priority + treaty.
Per CARDINAL [[feedback-conductor-heterogeneous-compute-no-second-class-
resources]] + [[feedback-parallel-companion-multimodal-dnd-real-time]]:
when multiple cells want the same scarce resource (VRAM bytes,
CPU microseconds, NVMe iops), the arbiter decides who gets it based
on priority + active treaty + current allocation share. REFUSES the
"first-come-first-served leads to starvation of low-rate streams" and
"highest-priority-always-wins leads to background-cell death" failure
modes.
V1 ships sealed resource enum + request enum + grant verdict +
per-cell allocation tracking + max-share fairness floor (no cell gets
>X% in a single epoch) + per-resource budget pool.
dependencies 2 imports · 7 importers
imports: nx_syscalls.nxnx_tier.nx
imported by: nx_bench_companion.nxnx_bench_companion_test.nxnx_companion_compose_test.nxnx_resource_arbiter_test.nxnx_session.nxnx_session_test.nxnx_swarm_arbitrate.nx
structs
| 43 | struct NxAllocation |
| 55 | struct NxResourceArbiter |
consts
| 21 | const NX_RA_KIND_VRAM_BYTES: nx_int = 0 |
| 22 | const NX_RA_KIND_RAM_BYTES: nx_int = 1 |
| 23 | const NX_RA_KIND_DISK_BYTES: nx_int = 2 |
| 24 | const NX_RA_KIND_CPU_MICROSECONDS: nx_int = 3 |
| 25 | const NX_RA_KIND_GPU_MICROSECONDS: nx_int = 4 |
| 26 | const NX_RA_KIND_NETWORK_BYTES: nx_int = 5 |
| 27 | const NX_RA_KIND_FILE_HANDLES: nx_int = 6 |
| 28 | const NX_RA_KIND_N: nx_int = 7 |
| 32 | const NX_RA_V_GRANTED_FULL: nx_int = 0 |
| 33 | const NX_RA_V_GRANTED_PARTIAL: nx_int = 1 // less than requested |
| 34 | const NX_RA_V_DENIED_NO_BUDGET: nx_int = 2 |
| 35 | const NX_RA_V_DENIED_MAX_SHARE: nx_int = 3 // would exceed fairness cap |
| 36 | const NX_RA_V_DENIED_PREEMPTED: nx_int = 4 // higher-pri cell took it back |
| 37 | const NX_RA_V_INVALID: nx_int = 5 |
| 38 | const NX_RA_V_NULL: nx_int = 6 |
| 39 | const NX_RA_V_N: nx_int = 7 |
| 53 | const NX_RA_A_BYTES: nx_int = 56 |
| 69 | const NX_RA_BYTES: nx_int = 56 |
functions
| 73 | func nx_ra_kind_is_valid(k: nx_int) -> nx_int |
| 79 | func nx_ra_v_is_valid(v: nx_int) -> nx_int called by 1: main |
| 87 | func nx_ra_new(capacity: nx_int) -> *NxResourceArbiter |
| 111 | func _ra_alloc_at(a: *NxResourceArbiter, idx: nx_int) -> *NxAllocation |
| 120 | func nx_ra_set_budget(a: *NxResourceArbiter, |
| 130 | func nx_ra_set_max_share(a: *NxResourceArbiter, |
| 142 | func nx_ra_get_budget(a: *NxResourceArbiter, resource_kind: nx_int) -> nx_size |
| 151 | func nx_ra_total_held(a: *NxResourceArbiter, resource_kind: nx_int) -> nx_size |
| 163 | func nx_ra_held_by_cell(a: *NxResourceArbiter, |
| 184 | func nx_ra_request(a: *NxResourceArbiter, |
| 249 | func nx_ra_release(a: *NxResourceArbiter, |
| 271 | func nx_ra_preempt(a: *NxResourceArbiter, |
| 299 | func nx_ra_grants_full(a: *NxResourceArbiter) -> nx_int |
| 304 | func nx_ra_grants_partial(a: *NxResourceArbiter) -> nx_int |
| 309 | func nx_ra_denials(a: *NxResourceArbiter) -> nx_int |
| 314 | func nx_ra_preemptions(a: *NxResourceArbiter) -> nx_int |