Execution · 5 minutes
Run loop starvation
A 100 ms timer deliberately blocks its own thread. Observe why the next dispatch arrives roughly 400 ms later.
swift run os-lab runloopView source ↗Live operating-systems lab
Seven small programs turn OS vocabulary into observable behavior: timer starvation, scheduler intent, data races, virtual memory, process boundaries, dynamic linking, and the AppKit event loop.
One-time setup
Build from Terminal. The package uses only Swift, Foundation, Darwin, Dispatch, and AppKit—no downloads or third-party dependencies.
$ cd ~/Downloads/OSConceptLab
$ swift build
$ swift run os-lab runloop
Seven runnable concepts
Check a lab only after you can explain its output without reading the source. Each source link opens the exact program you ran.
Execution · 5 minutes
A 100 ms timer deliberately blocks its own thread. Observe why the next dispatch arrives roughly 400 ms later.
swift run os-lab runloopView source ↗Scheduling · 7 minutes
Submit equal simulated work with three quality-of-service classes and compare the observed start and finish order across runs.
swift run os-lab schedulingView source ↗Concurrency · 8 minutes
Run 200,000 concurrent increments against racy and locked counters. A correct-looking racy result is still invalid.
swift run os-lab raceView source ↗Memory · 8 minutes
Reserve a 64 MiB virtual mapping, then touch one byte per page and watch peak resident memory change.
swift run os-lab vmView source ↗Processes · 7 minutes
A parent sends bytes through a pipe to a child process and handles its response, EOF, lifecycle, and exit status.
swift run os-lab ipcView source ↗Binary contract · 6 minutes
Ask dyld for malloc, resolve its runtime address, and identify the loaded Mach-O image that supplies it.
swift run os-lab dyldView source ↗Native AppKit · 12 minutes
Open a native window with a pulse and event log. Compare a 600 ms main-thread block with cancellable CPU work performed off the main actor and delivered through MainActor.
swift run event-loop-labView source ↗Read the causal line
The examples avoid architecture noise. Read the highlighted operation, predict its OS consequence, then verify that prediction with output.
if timeline.tick == 3 {
Thread.sleep(forTimeInterval: 0.35)
}The timer is ready, but its handler cannot run until this thread returns to the run loop.
for offset in stride(from: 0,
to: regionSize, by: pageSize) {
bytes[offset] = 1
}One write per page turns an address-space reservation into resident, dirty memory.
Your Apple second mate
The coach keeps prior career evidence separate from newly demonstrated lab evidence, scores causal depth, and will not count “I read it” as proof.
Personal coaching records are intentionally excluded from this public convenience copy.