feat(v4.0.0): a node asks its kernel by a blocking write to its port

ENGINE.md step 2, the carrier.  Ruled 2026-10-05 (V3-PARITY.md 1i), on
DECOMPOSITION.md section 6: a write to a port blocks until the neighbour
reads.

- node: v4_node_port_attach, v4_node_port_served; a store to the port keeps
  the value as the request and blocks the node
- exec: a blocked node executes nothing; served, it goes on from the opcode
  after the store, in the same instruction word; a fault meanwhile abandons
  the rest of the word
- compile.v4: n KERNEL-WORD name makes a word whose body writes n to the
  port; its arguments and results are on the data stack
- boot: the kernel's words are made by handing the node text, and requests
  are served between the node's opcodes; one no one serves is error 12
- BYE, the first kernel word: hosted it leaves the program, as hosted v3;
  on the lone node it is v3's cold restart
- ENGINE.md 3a: multiuser, multitasking, preemptive and cooperative, and
  what that asks of the engine

Verified: make -C v4 test passes at both widths, with tests/test_port.c;
hosted-check passes on three ISAs; clean qemu with STARFORTH_V4=1 on amd64,
aarch64 and riscv64 passes POST with the same hashes as hosted, and a
kernel word no one serves and BYE typed at each prompt are answered
(logs/20261005-185506, -185734, -190101; -185234 is an amd64 run in which
those two lines were not typed).

Not done: v3's own C functions serving a node.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rajames
2026-10-05 19:03:03 -04:00
co-authored by Claude Opus 5.5
parent 5f1f60fc84
commit 8df6c16766
21 changed files with 908 additions and 21 deletions
+18
View File
@@ -18,6 +18,7 @@
*/
#include "starkernel/v4/sk_v4.h"
#include "starkernel/console.h"
#include "starkernel/arch.h"
#include "v4/boot.h"
#define SK_V4_BLOCKS 64u
@@ -43,6 +44,22 @@ static int sk_v4_key(void)
return c < 0 ? V4_BOOT_KEY_NONE : c;
}
/* THE KERNEL'S WORDS for the lone node. BYE is v3's (mama_word_bye): a cold
* restart. v3's reaps Hera's children first; the lone node is started
* before there is a fleet, so there are none. The rest of the kernel's
* words come when the node is brought up in the VM's place (ENGINE.md
* step 4), where v3's own functions serve them. */
static const char *const sk_v4_words[] = { "BYE" };
static void sk_v4_serve(v4_node *node, unsigned request)
{
(void)node;
if (request == 1) {
console_println("BYE: cold restart");
arch_cold_reset();
}
}
/* Read a line from the keyboard: characters are echoed, backspace rubs one
* out, Enter ends it. Returns its length. */
static unsigned sk_v4_readline(void)
@@ -68,6 +85,7 @@ void sk_v4_run(void)
console_println("StarForth v4: one host node, the F18-derived engine");
boot.n = &sk_v4_node; boot.es = &sk_v4_es; boot.h = &sk_v4_heat; boot.im = &v4_capsule_image;
boot.out = sk_v4_out; boot.key = sk_v4_key;
boot.words = sk_v4_words; boot.word_count = sizeof sk_v4_words / sizeof sk_v4_words[0]; boot.serve = sk_v4_serve;
if (!v4_boot_run(&boot, sk_v4_disk, SK_V4_BLOCKS)) {
console_println("StarForth v4: not started");
for (;;) { }