code wiki / (root) / nx_yield.nx

nx_yield.nx

buildroot/runtime/nx_yield.nx

6821 B159 linesdepth 3pulls 3 transitivereach 3 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_yield.nx -- cooperative yield contract between cells. Per cardinal: cooperative-resource-arbitration. Yield is COOPERATIVE, not preemptive. A cell declares a yield-within-N-microseconds contract on instantiation; if a higher-priority class requests the contested resource, the cell receives a yield signal and must release within its declared quantum. Cells that miss their quantum are first demoted (priority dropped one rung) and then throttled (forced sleeps inserted until they catch up). This is the structural EXCEED-axis vs preemptive OS scheduling: preemption causes cache-line invalidation and TLB shootdowns that tank foreground game frame budget. Cooperative yield lets the preempted cell hit a clean checkpoint before releasing, preserving L1/L2 state for the in-coming foreground. Composes: nx_attention_class -- determines who yields to whom nx_budget -- yield can free budget headroom for waiter nx_evict_journal -- DEMOTED / THROTTLED outcomes logged nx_homeostasis -- repeat-misser cells become migration targets V1 ships a single shared resource model. Per-resource arbitration queues (RAM vs VRAM vs CPU) are queued; today all five resources arbitrate via one contention check. Gap list (V1 honest perf verdict): - no priority-inheritance to avoid inversion - no per-resource arbitration queues (single contention model) - no monotonic clock integration (caller supplies tick_us) - no automatic re-promotion after throttle (caller must reset) genealogy_id: nishi_cardinal_2026-05-17_cooperative_resource_arbitration lineage_id: substrate_yield_v1 nx_safety_envelope: intended_use: "Cooperative yield contract enforcement; contested resources released within quantum" sil_target: SIL2 evidence: [contract_declared_at_instantiation,

dependencies 3 imports · 3 importers

nx_syscalls.nx nx_tier.nx nx_attention_class.nx nx_yield.nx nx_ecosystem_compose_test.nx nx_substrate_compose_test.nx nx_yield_test.nx

imports: nx_syscalls.nxnx_tier.nxnx_attention_class.nx

imported by: nx_ecosystem_compose_test.nxnx_substrate_compose_test.nxnx_yield_test.nx

structs

65struct NxYieldContract

consts

52const NX_YIELD_OK: nx_int = 0 // grant, holder keeps resource
53const NX_YIELD_GRANTED: nx_int = 1 // request succeeded, holder yielded
54const NX_YIELD_DENIED: nx_int = 2 // requester lower prio, no yield
55const NX_YIELD_DEMOTED: nx_int = 3 // holder missed quantum, dropped a rung
56const NX_YIELD_THROTTLED: nx_int = 4 // holder repeatedly missed, throttled
57const NX_YIELD_ERR_BAD_ARGS: nx_int = 5
77const NX_YIELD_MISS_DEMOTE_AT: nx_int = 1
78const NX_YIELD_MISS_THROTTLE_AT: nx_int = 3
79const NX_YIELD_THROTTLE_FOR_US: nx_size = 50000

functions

83func nx_yield_contract_new(cell_id: nx_int,
called by 2: mainmain calls 1: sys_mmap
108func nx_yield_request(holder: *NxYieldContract,
148func nx_yield_checkpoint(holder: *NxYieldContract, now_us: nx_size) -> nx_int
called by 1: main
156func nx_yield_is_throttled(holder: *NxYieldContract, now_us: nx_size) -> nx_int
called by 1: main