threads(M6): getCurrentId, docs, and CI wiring — threading built

New thread_self=42 syscall backs runtime.Thread.getCurrentId (the calling
thread's kernel task id). thread-test gains an id mode: two workers read
getCurrentId and the main thread confirms all three ids are non-zero and
distinct. Per-thread threadlocal TLS is deferred by design (no consumer; it would
need context-switched fs.base for an unused feature), as are RwLock/WaitGroup.

Marks the threading feature built (M1-M6): threading.md + docs/README.md status
updated, all thread-* cases wired into qemu_test.py.

Gate thread-id PASS; full suite green: 21/21 (thread-spawn/join/futex/mutex/id,
aspace-refcount, + 15 guardrail cases), zig build clean, zig build test green.
This commit is contained in:
2026-07-20 21:55:13 +01:00
parent 1b33f48acd
commit def34e71fc
9 changed files with 149 additions and 25 deletions
+10 -7
View File
@@ -1,12 +1,15 @@
# Threading: `runtime.Thread`, a std-shaped API over a private thread ABI
A design note (not built yet) for giving danos **threads** — several tasks sharing
one address space — through a `runtime.Thread` type that mirrors the shape of Zig's
`std.Thread` while keeping every kernel entry behind the [runtime](../library/runtime).
It is forward-looking, like [zig-self-hosting.md](zig-self-hosting.md) and
[vision.md](vision.md): it fixes the decisions now so the code we write bends toward
them. The analysis is against **Zig 0.16** (the pinned toolchain); `std.Thread`'s
internals move between releases, so treat upstream shapes as "0.16.x."
A note on danos **threads** — several tasks sharing one address space — provided by a
`runtime.Thread` type that mirrors the shape of Zig's `std.Thread` while keeping every
kernel entry behind the [runtime](../library/runtime). **Built** (M1–M6, see
[threading-plan.md](threading-plan.md)): `spawn`/`join`/`detach`, cross-core
parallelism, a futex (`futex_wait`/`futex_wake`), and a futex-backed
`Mutex`/`Condition`/`Semaphore`, plus `getCurrentId`/`currentCore`. Deferred by design
(no consumer yet): per-thread `threadlocal` TLS, `RwLock`/`WaitGroup`, and migrating
`join` to a futex completion word — see the plan's M5/M6 notes. The analysis is against
**Zig 0.16** (the pinned toolchain); `std.Thread`'s internals move between releases, so
treat upstream shapes as "0.16.x."
## The win condition