FFramework Week
Progress saved locallySwift 6 · macOS

Live operating-systems lab

Predict it. Run it. Explain the mechanism.

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

The code is already here.

Build from Terminal. The package uses only Swift, Foundation, Darwin, Dispatch, and AppKit—no downloads or third-party dependencies.

Terminal
$ cd ~/Downloads/OSConceptLab
$ swift build
$ swift run os-lab runloop
The interview loop: predict the result → run twice → name the mechanism → identify production evidence → state the tradeoff in 90 seconds.

Seven runnable concepts

One mechanism at a time.

Check a lab only after you can explain its output without reading the source. Each source link opens the exact program you ran.

01

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.

Predict: which tick moves?Explain: why was nothing “lost”?
swift run os-lab runloopView source ↗
02

Scheduling · 7 minutes

QoS is intent, not ordering

Submit equal simulated work with three quality-of-service classes and compare the observed start and finish order across runs.

Predict: will high QoS always start first?Explain: what does QoS promise?
swift run os-lab schedulingView source ↗
03

Concurrency · 8 minutes

Race versus explicit ownership

Run 200,000 concurrent increments against racy and locked counters. A correct-looking racy result is still invalid.

Predict: how many increments disappear?Explain: confinement, actor, or lock?
swift run os-lab raceView source ↗
04

Memory · 8 minutes

Virtual is not resident

Reserve a 64 MiB virtual mapping, then touch one byte per page and watch peak resident memory change.

Predict: what changes after mmap?Explain: clean, dirty, resident, virtual.
swift run os-lab vmView source ↗
05

Processes · 7 minutes

Values cross; objects do not

A parent sends bytes through a pipe to a child process and handles its response, EOF, lifecycle, and exit status.

Predict: which state is shared?Explain: what more does XPC require?
swift run os-lab ipcView source ↗
06

Binary contract · 6 minutes

Find a live symbol

Ask dyld for malloc, resolve its runtime address, and identify the loaded Mach-O image that supplies it.

Predict: which image owns malloc?Explain: source versus binary compatibility.
swift run os-lab dyldView source ↗
07

Native AppKit · 12 minutes

Freeze the event loop, then free it

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.

Observe: pulse, click, key, redraw.Explain: which work waited and why?
swift run event-loop-labView source ↗

Read the causal line

The smallest code that proves the model.

The examples avoid architecture noise. Read the highlighted operation, predict its OS consequence, then verify that prediction with output.

Run loop

Blocking delays servicing.

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.

Virtual memory

Touching faults pages in.

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

Practice one question at a time.

The coach keeps prior career evidence separate from newly demonstrated lab evidence, scores causal depth, and will not count “I read it” as proof.

  1. QuestionOne bounded Apple-style prompt.
  2. AnswerSymptom → mechanism → evidence → tradeoff.
  3. ProbeOne follow-up based on your weakest link.
  4. RecordScore and durable evidence only.

Personal coaching records are intentionally excluded from this public convenience copy.