Skip to content

Open source. Linked to the real code.

How macOS really works.

Every box is a real part of the kernel. Pan around, zoom in, and click a subsystem to dive from the whole system down to the source.

XNU / Darwin architectureThe four canonical layers Apple defines for the XNU kernel environment: application environments at the top, system libraries and daemons, the kernel itself (Mach + BSD + I/O Kit + libkern), and hardware at the bottom. A security stack on the right intersects every layer.APPLICATION ENVIRONMENTSAppsApp Store · CLI · GUIApp frameworksCocoa · UIKit · SwiftUIMetal · CoreImagegraphics + MLFoundation · CombineObj-C / Swift runtimeSYSTEM LIBRARIES & DAEMONSlibSystemlibc · libpthread · libmlibdispatchGCD queuesdylddynamic loaderlaunchd · mDNSResponderPID 1 + system servicesUSER / KERNEL BOUNDARY — THREE API TIERSsysent[+n] · BSD syscallmach_trap_table[−n]IOUserClient · mach_msgKERNEL ENVIRONMENT (XNU)Machtasks · threads · ports · IPCscheduler · exception deliveryBSDproc · syscalls · signals · ucredthe POSIX personalityI/O KitIOService · IORegistryC++ driver frameworkvm_*, thread_*mach_msgVirtual memoryvm_map · vm_object · pmapVFS + APFSvnode · vnop_* · apfs.kextlibkern · DriverKitOSObject · userland driversVM compressor · jetsamreclaim under pressureNetwork stack4.4 BSD · TCP/IP · Skywalkkextslegacy in-kernel modulesHARDWARECPU / MMUSSD · APFS HWGPU / NPUSecure EnclavePCIe · USBDRAMSEP storageSensors · Display · Wi-Fi · Bluetooth · PowerSECURITYCode signingevery binarySandboxSBPL profilesEntitlementscapability grantsSIPcsrutilSealed System VolumeMerkle rootTCCuser consentSEP-backed keysFileVaultAPRR · KPPhardware-enforced
Click any subsystem to dive in

What is macOS internals?

macOS internals means the machinery under the Finder: the kernel, what launchd starts at boot, the dynamic linker, APFS, and the security layers that decide whether a binary gets to run at all. The open-source part is Darwin. Its kernel is XNU.

XNU is a hybrid, and the seams show. Mach owns tasks, threads, ports, the scheduler and virtual memory. The BSD layer bolted on top gives you processes, POSIX syscalls, signals, sockets and the VFS, which is why a process on macOS is both a BSD proc and a Mach task, with two different handles. IOKit, a restricted C++ framework, sits between drivers and the hardware. In user space, launchd is PID 1 and dyld loads every executable and its libraries, usually straight out of the shared cache.

Every explanation here links to the exact file and line in Apple's published source, because the docs stop long before the interesting parts.

XNUMach portsBSD personalityIOKitlaunchddyldAPFS

Reading apple-oss-distributions/xnu

apple-oss-distributions/xnu is Apple's official GitHub mirror of the kernel source, with one tag per drop, such as xnu-12377.121.6. Most of your reading time goes into a handful of top-level directories:

osfmk/
Mach: tasks, threads, ports and IPC, the scheduler, and the machine-dependent VM and pmap code
bsd/
The BSD personality: processes, syscalls, signals, the VFS, sockets and the network stack
iokit/
The IOKit driver framework: IORegistry, IOService matching and power management
libkern/
Kernel C++ runtime, OSObject, atomics and kext support
security/
The MAC framework that the Sandbox and AMFI policies hook into
san/
Kernel sanitizers such as KASAN
tests/
Darwin tests that exercise kernel behavior from user space

git clone https://github.com/apple-oss-distributions/xnu, then git checkout the tag that matches your OS build. Two caveats. Source drops land some time after a macOS release, so the newest point release is often missing. And building a kernel you can actually boot needs the matching Kernel Debug Kit, so almost everyone reads XNU rather than builds it.

Latest articles

Articles →
launchd is PID 1 on macOS: it starts every daemon and agent. Plist locations, launchctl domains, on-demand launch, and how to debug a job that will not start.
What runs in the first microseconds of a Mac boot — the SoC's Boot ROM, the Apple-signed LLB and iBoot stages, the SEP coming up alongside, and how the chain of trust starts.
The gauntlet every newly-downloaded app passes through — quarantine xattr, signature check, notarization check, user prompt. Where each decision is made and how to debug it.