← board

Meta: multithreading — libc-free Pascal threads (umbrella / epic)

Invariant (all multithreading tickets)

Self-host is single-threaded and stays that way. Every threading feature is opt-in (a uses/flag/directive), off by default, and MUST NOT change the single-threaded self-build — which stays byte-identical (the gate). Because of this, milestones can land in any order; nothing here is allowed to perturb the default single-threaded path. No libc — Linux syscalls only.

Architecture — one PAL, two consumers

A single libc-free PAL thread layer (Linux clone(2) + futex(2) + mmap'd stacks) underlies BOTH:

Don't build two thread layers — the C shim is a thin façade over the same PAL.

Milestones (land in any order; safety gates using threads, not building them)

Current state (2026-06-30 survey)

--threadsafe = x86-64 lock-prefix atomics on heap alloc + ARC refcounts (correct, unoptimized, x86-64-only). Threads today go through real libpthread.so.0 (test_multithreading.pas) — NOT libc-free. syncobjs TCriticalSection = parse-compat stubs. pthread unit = declarations only. No clone-based creation yet. So M1/M2 are the green-field keystone.

Progress — core stack LANDED bottom-up (2026-06-30, x86-64)

The libc-free threading stack is functional end to end on x86-64, all green in make test-threads, single-thread self-host byte-identical:

Tests: test_thread_clone, test_palthread, test_atomic_counter, test_mutex, test_tthread, test_event, test_thread_heap.

REMAINING (refinements, each ticketed): i386 trampoline + atomics (32-bit case of "intel/AMD"); condition variable / Once / TCriticalSection alias; TThread Synchronize/Queue + virtual destructor/auto-join; per-thread TLS (per-thread exception chain — ties to [[audit-shared-global-reentrancy-thread-safety]]); re-export TThread from classes; M5 heap optimisation (per-thread arenas). M4 C-pthread shim ([[feature-syscall-pthread-shim]]) can now reuse this PAL.

2026-07-02 update: M0 COMPLETE (heap contract v151 + I/O lock v146 + clear guards: __pxxclone requires --threadsafe, cross-target --threadsafe rejected). M3 gained Synchronize/Queue/CheckSynchronize + auto-join destructor (v152). M4 is UNBLOCKED and ready for Track B/C — entry point written in [[feature-syscall-pthread-shim]].

Log