Skip to content
Beskid Platform specification

Beskid

Jump to a Beskid service

Beskid

Jump to a Beskid service

System.Threading

Platform spec feature

System.Threading

Spec standingStandard

Owner
Piotr Mikstacki
Submitter
Piotr Mikstacki

What this feature specifies

System.Threading is the only supported preemptive OS-thread surface in corelib_concurrency. It wraps syscall-backed Spawn, Join, and Yield for kernel-scheduled threads. Cooperative fibers (Fiber<T>, Channel) must use the Concurrency package, not threads built in user code on top of this module.

Implementation anchors

Contract statement

System.Threading lives in the corelib_concurrency package under module prefix System.Threading. It wraps OS threads (preemptive, kernel-scheduled) using syscalls and/or documented extern targets—not fiber stack switching.

Cooperative concurrency must use Concurrency package (Fiber<T>, Channel). Do not implement fibers on top of System.Threading in corelib.

Responsibilities

API (illustrative)Role
Thread.SpawnStart OS thread with entry function; returns Result<Thread, ThreadError>
Thread.JoinWait for OS thread completion
Thread.YieldOS-level yield (distinct from Concurrency.Yield)

Fiber scheduler worker pool may use OS threads internally; user code should not confuse the two Yield entry points.

FFI and GC

OS thread entry points must establish a runtime heap session and GC root attachment per thread before calling Beskid code. extern “C” from any fiber or thread must stay pinned to the calling OS thread for the call duration (see Extern dispatch and policy).

Phase alignment

Phase A: fiber scheduler may use a fixed pool of OS threads with one GC mutator; System.Threading documents raw thread creation for libraries that truly need preemptive threads. Phase B: parallel GC mutators—thread module and fiber pool coordination updated in scheduler spec without renaming public Thread APIs.

No open decisions. Closed choices are normative ADRs under adr/ (D-CORE-SYST-0001D-CORE-SYST-0004); use the reader ADRs tab for expandable detail.