Commit Graph

3 Commits

Author SHA1 Message Date
Pooya Parsa
96598464f9 Build the CPU worker into the package and split the page's kernel
pnpm build inlines js/node/cpu-entry.ts where js/node/cpu.ts starts it,
in the Node entries and inside the inlined Node kernel worker (WORKERS
nested), so the package starts SMP CPUs without source files. The page
build serves web/kernel/page/: the bundle without its SMP patch section
(the same bytes when there is none) and, only with a patch, the SMP
bundle it makes as a second hashed asset (kernelSmpUrl, unused until the
page has CPU threads).
2026-11-17 10:44:16 +00:00
Pooya Parsa
55095f50bf Boot an SMP kernel on several CPUs in Node (SMP step 2)
A second kernel build (kw_smp.config) runs one instance of the module
per CPU, each in a worker thread on a shared memory. The host's Kernel
is CPU 0 with every device; wasm_cpu_start starts the others through
Platform.spawnCpu (js/node/cpu.ts), which run js/core/cpu.ts: their own
JSPI task switching, the clocks on CPU 0's time base, and console and
exit forwarded to CPU 0's host. The host sets IRQ bits atomically and
ends CPU 0's idle on Atomics.waitAsync of its word, which other CPUs'
IPIs notify. createKernel's cpus option and the CLI's --smp N (which
implies --worker) ask for CPUs; a UP kernel ignores them with a log
line, and more than one CPU runs the interpreter only.

kwemu built with -Dkwemu-atomics makes AMOs atomic, SC a
compare-and-swap against the value LR read, and FENCE a barrier (ABI
7). kwtest gains an smp check (threads on several CPUs counting
through AMOs, LR/SC and a mutex) and skips the park check on an SMP
kernel, which has no parking. The kernel side is in five new patches.
2026-11-16 16:07:40 +00:00
Pooya Parsa
26d08730cc Initial commit 2026-11-15 23:27:04 +00:00