code wiki / _hdl_build / nx_resmon_lib.nx
nx_resmon_lib.nx
buildroot/runtime/_hdl_build/nx_resmon_lib.nx
about
nx_resmon_lib.nx -- the PURE, GATEABLE core of nx_resmon (debt seq1005).
Split out per rule 9 (single responsibility) and rule 15 (DRY): the organ owns the /proc walk and
the printing, this lib owns the two predicates that actually encode the policy --
rm_is_leaker : what counts as a leaking process
rm_verdict : how measurements become GREEN / AMBER / RED
Keeping them here means the gate exercises the SAME code the organ runs, not a reimplementation.
Everything here is a pure function of its arguments (rm_field/rm_conf parse a caller-owned buffer),
so the gate needs no /proc, no files and no fixtures on disk.
license_tier: ORIGINAL
dependencies 1 imports · 5 importers
imports: nx_syscalls.nx
imported by: nx_adopt.nxnx_cpuid.nxnx_procchurn_lib.nxnx_resmon.nxnx_resmon_gate.nx
structs
| none |
consts
| none |
functions
| 13 | func rm_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 14 | func rm_puts(s: *u8) -> i64 { sys_write(1, s, rm_slen(s)); return 0 } |
| 15 | func rm_num(v: i64) -> i64 |
| 30 | func rm_read(path: *u8, buf: *u8, cap: i64) -> i64 |
| 48 | func rm_field(buf: *u8, n: i64, key: *u8) -> i64 |
| 84 | func rm_conf(cbuf: *u8, cn: i64, key: *u8, dflt: i64) -> i64 |
| 97 | func rm_is_leaker(vsz: i64, vpk: i64, rss: i64, swap: i64, min_kb: i64) -> i64 |
| 112 | func rm_verdict(swused_pm: i64, avail_pm: i64, leakers: i64, |