Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/spec/omegese-cpu-workers.md # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / spec / omegese-cpu-workers.md` 97 lines ยท 5561 bytes Raw Blame History Rendered 1 # CPU worker facilities 2 3 Status: DRAFT, ham/om-threads. Additive to OM-2 and the OM-3 draft. Not MERGED or DEPLOYED. 4 5 ## Scheduler words 6 7 Program mode, AArch64 Linux and x86linux only. Function mode is error 9, 8 x86efi error 25, a contract expression error 30. Every result is long, 9 a successful kernel result or minus errno. No allocation or privilege change. 10 11 | word | operands | kernel operation | 12 |---|---|---| 13 | cpuset | pid int, A byte array, off ulong, n ulong | sched_setaffinity | 14 | cpuget | pid int, A writable byte array, off ulong, n ulong | sched_getaffinity | 15 | cpunow | none | getcpu, CPU result only | 16 | setprio | which int, who int, priority int | setpriority | 17 | getprio | which int, who int | getpriority, raw kernel value 20 minus nice | 18 19 The byte slices are checked before the syscall (trap 3). Affinity masks use 20 Linux bit numbering, low CPU first. A zero pid means the calling thread, not 21 all threads. cpuget returns the number of mask bytes copied, not zero. 22 The kernel rejects a mask with no permitted online CPU with -22. cpuget needs 23 a sufficiently large, machine-word-sized buffer. cpunow is a snapshot, not a 24 promise about subsequent scheduling unless the thread has one allowed CPU. 25 setprio retains ordinary Linux authorization checks; it does not bypass nice 26 limits. which 0 is PRIO_PROCESS, who 0 the calling thread. Higher nice reduces 27 priority. These words are effects, never contract predicates. 28 29 Syscall authority: Linux asm-generic/unistd.h and x86 syscall_64.tbl. 30 AArch64 numbers: 122,123,168,140,141. x86linux: 203,204,309,141,140. 31 32 ## Reversible decision 33 34 Choose raw Linux scheduler operations and caller-owned buffers, not a hidden 35 worker runtime or allocator. Existing host words already use checked slices and 36 negative errno. Revert the additive host words and the benchmark caller to undo. 37 Thread design and its checked-sharing/lifecycle evidence will be a separate head. 38 39 ## Gate 40 41 seed/host/affinity/sched.cases uses the existing Omega OM-2 conductor. It checks 42 inherited-mask selection, single-core observation, readback, invalid mask and 43 pid, out-of-bounds slice, priority read/set/readback and invalid which. Compiler 44 mutants replace setaffinity by getaffinity on both targets; invalid-mask check 45 must catch both. x86 runs are EMULATED, not native x86 qualification. 46 47 bench/omc_efficiency/run.om calls cpuset/setprio in its conductor child instead 48 of launching taskset/nice. Other children and the coordinator retain their 49 inherited scheduler state. Pool locking remains the launcher's responsibility. 50 51 The priority child independently reads /proc/thread-self/stat field 19. Offset checks 52 use off 9 with sentinels; AArch64 and x86 offset-removal mutants must fail at 53 fixture exit 14. Set/get syscall-swap mutants must fail at exit 3. The fixture 54 also pins the last inherited core and checks cpunow there (exit 17/18), so a 55 cpunow that ignores the getcpu result fails even when the first inherited core 56 is CPU 0; the AArch64 and x86 load-removal mutants must fail at exit 18. The 57 last-core pin runs on every pool shape (on a one-core pool the last core is the 58 first), so exit 18 holds on single-core pools too; only a one-core mask of CPU 0 59 cannot tell a constant 0 from getcpu, and there the mutant rows fail. Under a nice 19 60 pool setprio 0 0 19 is a no-op, so the priority child also asks for nice 18: 61 without CAP_SYS_NICE the result must be -13 with nice still 19, and where it is 62 allowed nice must read 18 and raw getprio 2 (exit 19 otherwise). The AArch64 and 63 x86 mutants that hardwire the setprio operand to 19 must fail at exit 19. Caller cases 64 compose the existing run.om helpers with only its main replaced: cpk1, runpk, 65 child and selfpin run unchanged, then a real conductor child checks its single 66 allowed core and priority. Invalid CPU 1024 is refused with exit 118. 67 68 ## Constant provenance 69 70 WolframLanguageEvaluator query 71 `Table[{w,FromDigits[Reverse[ToCharacterCode[w]],256]},{w,{"cpuset","cpuget","cpunow","setprio","getprio"}}]` 72 returned `{cpuset,`127979077595235`}`, `{cpuget,`127978876268643`}`, 73 `{cpunow,`131320478265443`}`, `{setprio,`31359662648747379`}`, 74 `{getprio,`31359662648747367`}`. These are keyword encodings, not measurements. 75 76 ## Coordinator build and compatibility 77 78 Build run.om with this head's seeded compiler, even when its BASE argument is 79 an older compiler. BASE and CAND still select the benchmark arms; they do not 80 select the compiler used to build the coordinator. This is an implementation 81 addendum to the frozen OMC-EFF-4 driver description, not a change to its rounds, 82 metrics, validity rules, affinity target or priority adjustment. The frozen 83 protocol files and historical receipts are left unchanged. 84 85 selfpin runs after child working-directory and stream setup, immediately before 86 execprog. It preserves the former nice -n 19 adjustment, including an inherited 87 negative nice: getprio gives raw = 20 minus nice, so setprio gets 88 min(19,39 minus raw). WolframLanguageEvaluator 89 `FullSimplify[20 - raw + 19 == 39 - raw]` returned True. 90 The coordinator and unrelated subprocesses keep their inherited scheduler state. 91 92 The priority oracle is /proc/thread-self/stat because the Linux word targets 93 the calling thread. On the Spark's x86 emulator probe, /proc/self/stat supplied 94 synthetic zero priority/nice fields while /proc/thread-self/stat reported 95 priority 39 and nice 19, consistent with raw getprio 1. The per-thread oracle 96 therefore preserves an independent kernel check on both targets instead of 97 accepting the emulator's synthetic process record. No priority check is skipped.