code wiki / _hdl_build / nx_polite_loop.nx
nx_polite_loop.nx
buildroot/runtime/_hdl_build/nx_polite_loop.nx
about
nx_polite_loop.nx -- the team's RESOURCE-AWARE autonomous backlog loop (operator: "it needs to be resource
aware so when im playing a game or doing other things it should pause or run minimally based on the hardware
resources"). Composes the team's OWN governor: nx_sysload reads real /proc (load, ncpu, free mem) and
nx_resource_governor (POLITE) decides -> PAUSE when over the load ceiling (you're gaming/busy), run MINIMAL
(fewer tasks) under partial load, full when idle; always nice; memory-floor admission; AIMD backoff. A
/tmp/nishi_pause flag forces PAUSE (escape hatch + the hook a Windows GPU/foreground sensor can touch, since
WSL /proc can't see a Windows game directly). When allowed, it runs a backlog TICK by ITERATIVE reach (no
recursion -> dodges the regalloc segfault): the Builder composes each task or RAISES A HAND -> escalation
queue. license_tier: ORIGINAL
dependencies 3 imports · 0 importers
imports: nx_sysload.nxnx_resource_governor.nxnx_syscalls.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 18 | const PL_RESERVE: i64 = 1 // always leave 1 core for the foreground (your game/app) |
| 19 | const PL_CEIL_MILLI: i64 = 800 // per-core ceiling: load > 0.8*ncpu -> PAUSE (you're busy) |
| 20 | const PL_MEM_FLOOR_MB: i64 = 1024 // don't start work under 1 GB free |
| 21 | const PL_BASE_BACKOFF: i64 = 1000 // ms, grows AIMD with overload |
| 23 | const NTYPE: i64 = 8 |
| 24 | const NP: i64 = 8 |
| 25 | const NTASK: i64 = 6 |
functions
| 14 | func pl_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 15 | func pl_putn(v: i64) -> i64 { let b: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m;sys_write(1,"-" as *u8,1)}; let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48 as u8;k=1}; while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1}; var i: i64=0; while i<k{b[i]=t[k-1-i];i=i+1}; sys_write(1,b,k); return 0 } |
| 28 | func pl_reach(tin: i64, tout: i64, pin: *i64, pout: *i64, pav: *i64) -> i64 |
| 44 | func main() -> i64 |