← board

Sync primitives on futex — TCriticalSection/TMutex/TEvent/Once + atomics (M2)

Invariant

Threading is opt-in, off by default; the single-threaded self-build stays byte-identical. No libc — built on [[feature-pal-thread-primitives]] (syscalls only). Milestones land in any order under [[meta-multithreading]].

Scope

Real synchronisation on PalFutexWait/Wake, replacing today's parse-compat stubs in lib/rtl/syncobjs.pas (TCriticalSection methods are currently no-ops):

Acceptance

Status — M2 first slice LANDED (2026-06-30)

DONE (x86-64):

REMAINING in M2:

Update — TEvent landed (2026-06-30)

TEvent (manual/auto-reset) added to lib/rtl/palsync.pas on the futex: EventInit/ Set/Reset/Wait. Manual = level-triggered "go gun" (wakes all, lost-wakeup-safe either order); auto = one-waiter hand-off (CAS-consumes the signal). test_event (manual start gun, 4 waiters) in make test-threads. Still remaining: condition variable, Once. TCriticalSection alias still pending (with M3).

Update — TRTLCriticalSection (FPC API) + RunOnce landed (2026-06-30)

Update — M2 COMPLETE: TConditionVariable + 64-bit atomics (2026-07-03)

M2 fully closed: TMutex, TEvent, TRTLCriticalSection, RunOnce, TConditionVariable, 32+64-bit atomics.