skip to content
==> README.md <==
1# @ajax/mesh-driver
2
3meshd's driver thread: the only ring publisher and program-table writer; lifecycle, blinks, publishing, pipes and job items.
4
5meshd's driver thread (driver.rs).
6
7The only publisher of every ring and the only writer of the program table. Each tick it collects completions, honours run requests and commands, and publishes the next tasks of every loaded program -- each its own resident kernel (or wasm lanes, or a native worker) with its own ring.
8
9Lifecycle (plan §3.1): start/stop launch or halt one program's kernel and touch nothing else (zero gap). Anything that changes the context's module set (load, upgrade, unload --now) is a *blink*, because module loads and unloads block while any kernel of the context runs: drain every ring, halt every kernel, do the module operations (images compiled beforehand on a worker thread), rewind each ring head to its published tail, launch everything that runs, then wait for all of it. Rollback and reset need no module operation: they blink only their slot. Isolated executors (mps, the CPU executors) blink only the slot a module change touches.
10
11Executors are per slot (mesh-abi PX_EXEC): the GPU backend and beside it the CPU executors (wasm lanes, native worker processes). A load runs on the first executor its manifest's `backends` lists that this meshd has.
12
13```c
14#include "mesh/driver.h"
15```
16
17## Ported from
18
19[alpha-rust-mesh](https://github.com/rsafier/alpha-rust-mesh) (Richard Safier, MIT): crates/mesh-host/src/driver.rs (all of it: `Config`, `Job`, `Op`, `Blink`, `Waiter`, `Zombie`, `GoneInbox`, `DeadCell`, `JLease`, `JobSlot`, `SetupState`, `Driver` and every method), and programs.rs `Image`, `Phase`, `Slot`, `view_compatible`.
20
21## Tests
22
23- `tests/driver.c`: driver.rs's `job_setup_in_order` and `reads_by_name`; and the driver end to end over a fake CPU executor whose nodes are a thread playing mesh-rt's node loop: autoload (and a program it may not run), the blink, OP_INIT, tasks, refusals, stop and start, reset, `--state`, unload and load into the freed slot, shutdown.
24- apps/meshd's test runs it with the real wasm and native executors.
25
26## Differences
27
28- **Placement (place.rs) is not wired**: no placer is ever created (as in a single meshd, or a program without `place`), so `place` answers "declares no `place`" when peered and F_PLACE/F_FRAME from members are logged and dropped. The fleet area's @ajax/mesh-placer provides the Placer; wiring it means `sync_place`, `place_acts`, `apply_mode`, `place_tick`, `place_frame` and the role checks in `publish_slot`, `ProgRun`, `Reset` and `Input`.
29- The JIT runs one detached thread per load or upgrade, as the Rust's `std::thread::spawn`.
30
31## Licence
32
33MIT. See the repository's LICENSE.