code wiki / _hdl_build / nx_qserver.nx
nx_qserver.nx
buildroot/runtime/_hdl_build/nx_qserver.nx
about
nx_qserver.nx -- MULTI-SLOT sovereign job queue: one persistent process that scans a directory for *.job
files (sys_getdents64, the same syscall nx_claude_bridge's ls uses) and runs each, so the agent loop can
have MANY jobs in flight (vs nx_jobserver's single fixed slot). Per job <base>.job:
read it (line1 elf, lines2.. args VERBATIM) -> fork/exec directly with a WATCHDOG (kill -9 at <watchdog>s)
-> capture stdout+stderr -> <base>.out -> write exit code -> <base>.res -> delete <base>.job (consume).
Collects names FIRST, then processes (so unlinking never disturbs the getdents scan). Stop via <dir>/nxq.stop.
usage: nx_qserver <queuedir> <pollbudget> <watchdog-sec> (budget=0 = forever). No sh, no quoting.
Sovereign: nx_syscalls only. license_tier: ORIGINAL
dependencies 2 imports · 0 importers
imports: nx_syscalls.nxnx_itoa_lib.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
| 11 | const K_MAGIC_1000000: i64 = 1000000 |
| 12 | const K_MAGIC_65536: i64 = 65536 |
| 13 | const K_MAGIC_1024: i64 = 1024 |
functions
| 15 | func qs_w(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } |
| 20 | func qs_wn(v: i64) -> i64 { nxi_out(v); return 0 } |
| 21 | func qs_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 22 | func qs_atoi(s: *u8) -> i64 { var v: i64 = 0; var i: i64 = 0; while s[i] != (0 as u8) { let c: i64 = s[i] as i64; if c >= 48 { if c <= 57 { v = v * 10 + (c - 48) } } i = i + 1 } return v } called by 1: main |
| 23 | func qs_unlink(path: *u8) -> i64 { __syscall(263, AT_FDCWD, path, 0, 0, 0, 0) return 0 } |
| 24 | func qs_sleep_ms(ms: i64) -> i64 { let ts: *i64 = sys_mmap(16) as *i64; ts[0] = ms / 1000; ts[1] = (ms % 1000) * K_MAGIC_1000000; return __syscall(SYS_CLOCK_NANOSLEEP, 0, 0, ts, 0, 0, 0) } |
| 29 | func qs_wn_fd(fd: i64, v: i64) -> i64 { nxi_fd(fd, v); return 0 } |
| 30 | func qs_path(dir: *u8, name: *u8, out: *u8) -> i64 |
| 39 | func qs_rpath(dir: *u8, name: *u8, namelen: i64, suffix: *u8, out: *u8) -> i64 called by 1: qs_scan |
| 48 | func qs_ends_job(name: *u8) -> i64 |
| 58 | func qs_run_job(reqbuf: *u8, n: i64, out_path: *u8, wdog_sec: i64) -> i64 |
| 95 | func qs_scan(dir: *u8, wdog: i64) -> i64 |
| 148 | func main(argc: i64, argv: *i64) -> i64 |