danos/library/runtime
Daniel Samson 73df864fd2 threads(M2): thread_spawn/thread_exit + runtime.Thread.spawn
A thread is a task sharing the caller's address space. New private syscalls
thread_spawn(entry, stack_top, arg)=37 and thread_exit=38: thread_spawn goes
through scheduler.spawnThread (retains the shared aspace), thread_exit ends the
task like a process exit(0) (terminateCurrent -> releaseAspace, so the space
survives while siblings hold it). The closure pointer reaches the new thread in
rdi via a new jump_to_user_arg asm path and a per-task user_arg (0 for a normal
process, whose _start ignores it) - so the runtime trampoline is a plain C-ABI
Zig function, no naked asm.

runtime.Thread (library/runtime/thread.zig) mirrors std.Thread.spawn: mmap a
stack, heap-allocate the args closure, hand the kernel the trampoline + closure.
addThreadedUserBinary opts a binary into single_threaded=false; thread-test is
the first, and proves a worker runs in the shared address space via a shared
global the main thread polls.

Gate thread-spawn PASS; 16 guardrail cases green (incl. args/init/process on the
new jump_to_user_arg path) + aspace-refcount; build + host tests clean.
2026-07-20 21:04:23 +01:00
..
block.zig fat/usb-storage: flush the device cache on close so writes survive power-off 2026-07-13 23:29:15 +01:00
device.zig WIP: USB 2026-07-12 22:24:47 +01:00
display.zig display: runtime mode-setting, EDID, and fenced (vsync) present (v2 V5) 2026-07-14 12:44:21 +01:00
dma.zig M14b: DMA memory (dma_alloc / dma_free) 2026-07-10 19:43:59 +01:00
fs.zig Phase 2d (ii): filesystem modification time (mtime) 2026-07-13 20:43:40 +01:00
heap.zig Split the `system` contract into boot-handoff / abi / device-abi 2026-07-10 18:08:51 +01:00
input.zig fixing comments 2026-07-12 16:19:09 +01:00
ipc.zig Signals over IPC, one-shot timers, and the service harness (M17.4) 2026-07-12 23:53:38 +01:00
process.zig Signals over IPC, one-shot timers, and the service harness (M17.4) 2026-07-12 23:53:38 +01:00
root.zig removing the need for panic and _start snippets in user space binaries 2026-07-17 16:15:30 +01:00
runtime.zig threads(M2): thread_spawn/thread_exit + runtime.Thread.spawn 2026-07-20 21:04:23 +01:00
service.zig The application surface: enumerate, subscribe, and device-list (M18.3) 2026-07-13 00:49:03 +01:00
shm.zig display: hot-attach a virtio-gpu native backend over the GOP floor (v2 V4) 2026-07-14 12:21:37 +01:00
start.zig removing the need for panic and _start snippets in user space binaries 2026-07-17 16:15:30 +01:00
system-call.zig zig fmt 2026-07-12 16:04:58 +01:00
system.zig Phase 2d (i): a kernel wall-clock from the CMOS RTC 2026-07-13 20:35:03 +01:00
thread.zig threads(M2): thread_spawn/thread_exit + runtime.Thread.spawn 2026-07-20 21:04:23 +01:00
time.zig Add runtime.time, drop demo drivers, harden TSC timekeeping 2026-07-13 11:56:43 +01:00
usb.zig USB driver stack: xHCI transfers, HID keyboard/mouse, mass storage 2026-07-13 14:11:00 +01:00
user.ld Re-organize the source tree as a monorepo mirroring the FHS 2026-07-10 12:55:56 +01:00