- worker DB builtins marshal to shard 0: requester-side slot encode (VM heaps never read cross-shard), owner executes serialized in adopt, reply unparks via new WO_PARK_INBOX park + envelope 3/4 - engine gains thread-agnostic slot entry points (insert_slots, update_field_slot, val_encode/clone, wo_db_exec_req); traps and messages byte-identical to the local path - main.c: engine + replay boot BEFORE shards spawn; workers assert rt.db/rt.wal NULL; busy shard adopts inbox once per slice - latent stage-1 bug fixed: shared io_uring params static raced by lazy worker init lost park wakes (~1/20 hangs); params per-vm, short submit now fails loud - new sample docs/examples/db-actor + just db-actor gate 8/0 (multi x3, uring/epoll forced, single byte-exact, WAL replay pair); ASan+TSan 6/6; full battery green Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
40 lines
1.7 KiB
C
40 lines
1.7 KiB
C
/* park.h — the per-shard I/O plane (the 8+11 arc, stage 1 Task 4).
|
|
*
|
|
* One event loop per shard, io_uring-FIRST (developer directive; the linux
|
|
* reference project's "single event loop" card): parked fibers wait as
|
|
* POLL_ADD (fd readiness — resume RE-EXECUTES the now-ready builtin) or
|
|
* TIMEOUT (sleep — resume continues PAST the builtin) submissions on a raw
|
|
* ring. epoll is the PORTABILITY fallback, selected by a startup probe
|
|
* (seccomp'd containers routinely deny io_uring) or forced with
|
|
* WO_IO=uring|epoll so CI proves both paths on one kernel.
|
|
*
|
|
* Raw io_uring_setup/io_uring_enter syscalls, libc-only — struct layouts
|
|
* mirrored from include/uapi/linux/io_uring.h. Ops restricted to the
|
|
* TIMEOUT floor (Linux 5.4); multishot variants are recorded future work.
|
|
*/
|
|
#ifndef WO_PARK_H
|
|
#define WO_PARK_H
|
|
|
|
#include "vm.h"
|
|
|
|
/* Probe (or WO_IO-force) the backend. 0 ok; nonzero = no backend (fatal). */
|
|
int wo_io_init(wo_vm *vm);
|
|
void wo_io_destroy(wo_vm *vm);
|
|
|
|
/* Register the just-parked fiber's wait (fb->park_* already filled by the
|
|
* builtin). 0 ok; -1 = arming failed (caller traps the builtin as IO).
|
|
* park_fd == WO_PARK_INBOX joins the parked list with NO plane wait — the
|
|
* wake arrives as an inbox envelope (arc stage 3's DB reply). */
|
|
int wo_io_arm(wo_vm *vm, wo_fiber *fb);
|
|
|
|
/* Wake one parked fiber from OUTSIDE the plane (the inbox path: the DB
|
|
* actor's reply). parked list -> run queue. */
|
|
void wo_io_unpark(wo_vm *vm, wo_fiber *fb);
|
|
|
|
/* Block until at least one parked fiber wakes; woken fibers move to the
|
|
* run queue. 0 = something woke; WO_IO_STOP = the stop flag interrupted
|
|
* the wait (caller unwinds everything); -1 = fatal backend error. */
|
|
#define WO_IO_STOP (-2)
|
|
int wo_io_wait(wo_vm *vm);
|
|
|
|
#endif /* WO_PARK_H */
|