nx_yield.nx
buildroot/runtime/nx_yield.nx
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
imports: nx_syscalls.nxnx_tier.nxnx_attention_class.nx
imported by: nx_ecosystem_compose_test.nxnx_substrate_compose_test.nxnx_yield_test.nx
structs
| 65 | struct NxYieldContract |
consts
| 52 | const NX_YIELD_OK: nx_int = 0 // grant, holder keeps resource |
| 53 | const NX_YIELD_GRANTED: nx_int = 1 // request succeeded, holder yielded |
| 54 | const NX_YIELD_DENIED: nx_int = 2 // requester lower prio, no yield |
| 55 | const NX_YIELD_DEMOTED: nx_int = 3 // holder missed quantum, dropped a rung |
| 56 | const NX_YIELD_THROTTLED: nx_int = 4 // holder repeatedly missed, throttled |
| 57 | const NX_YIELD_ERR_BAD_ARGS: nx_int = 5 |
| 77 | const NX_YIELD_MISS_DEMOTE_AT: nx_int = 1 |
| 78 | const NX_YIELD_MISS_THROTTLE_AT: nx_int = 3 |
| 79 | const NX_YIELD_THROTTLE_FOR_US: nx_size = 50000 |
functions
| 83 | func nx_yield_contract_new(cell_id: nx_int, |
| 108 | func nx_yield_request(holder: *NxYieldContract, |
| 148 | func nx_yield_checkpoint(holder: *NxYieldContract, now_us: nx_size) -> nx_int called by 1: main |
| 156 | func nx_yield_is_throttled(holder: *NxYieldContract, now_us: nx_size) -> nx_int called by 1: main |