From ce43cb9554d443f12af886ee035a73bf9b322ac5 Mon Sep 17 00:00:00 2001 From: salmonik Date: Sat, 1 Aug 2026 16:19:45 +0200 Subject: docs: ADR 0003 (preemptive kernel tasks) + task glossary terms - ADR 0003: preemptive round-robin kernel tasks on the 100 Hz tick, shared address space, guard pages + page-fault handler, graceful task panics, safe-builtin spawn surface, only-shell-touches-I/O invariant - CONTEXT.md: new 'Task' glossary entry; 'Paging strategy' now says guard pages exist on task stacks --- CONTEXT.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'CONTEXT.md') diff --git a/CONTEXT.md b/CONTEXT.md index aa2392e..65475ce 100644 --- a/CONTEXT.md +++ b/CONTEXT.md @@ -32,7 +32,9 @@ structs are hand-defined (not from `uefi-rs` crate) to stay lightweight. Long mode mandates paging (`CR0.PG = 1`), so we accept that tax but keep it simple. Identity-mapped 4-level tables, no higher-half, no demand paging, -no guard pages. `paging.rs` provides identity map/unmap/query helpers. At +no guard pages except task stacks — each task's stack gets one unmapped +guard page below it, and a page-fault handler turns an overflow into a +task panic. `paging.rs` provides identity map/unmap/query helpers. At boot the kernel runs on UEFI's tables; `adopt_tables()` rebuilds that map into the kernel's own tables and switches CR3 — needed because UEFI maps its page-table pages read-only, so the firmware tree can't be modified in place. @@ -80,6 +82,19 @@ linear frame buffer is system memory that we own once boot services are gone. Scancode set 1, US QWERTY layout. Hardcoded scancode→ASCII table. Other layouts can be added later by swapping the translation table. +## Task + +A unit of concurrent execution in the kernel: its own kernel stack +(with a guard page below it), scheduler bookkeeping, and no +address-space separation — all tasks share the one identity-mapped +space and the kernel's facilities (TempleOS-style, not a process). +Tasks are preemptively round-robin-scheduled on the 100 Hz PIT tick; +the shell is task 0 and an idle `hlt` task is the always-ready +fallback. A task may sleep, yield, and log to serial/klog; only the +shell touches the disk, filesystem, and terminal. A panicking or +stack-overflowing task dies gracefully (logged, marked done, slot +reaped) without taking the kernel down. + ## Development loop Standalone project — no integration with the RNG initramfs build system. -- cgit v1.2.3