What is Mac OS X?

© Amit Singh. All Rights Reserved. Written in December 2003

Above the Kernel

This page discusses the software layers above the kernel in Mac OS X.

Mac OS X: Architecture

Core Services

The Core Services layer can be visualized as sitting atop the kernel. This layer's most important sub-components are CoreFoundation.framework and CoreServices.framework. It contains various critical non-GUI system services (including APIs for managing threads and processes, resource, virtual memory and filesystem interaction):

CoreFoundation also includes a large number of other services. For example, it provides ways so that applications can access URLs, parse XML, maintain property lists, etc. In the directory /System/Library/Frameworks/, refer to the directory CoreFoundation.framework/Headers/ for headers belonging to CoreFoundation.

Application Services

This layer can be visualized as being on top of Core Services. It includes services that make up the graphics and windowing environment of Mac OS X.

The core of the windowing environment is called Quartz. Quartz consists of broadly two entities:

While NeXT used "Display PostScript" (DPS) for the imaging model in NEXTSTEP, Quartz uses PDF for its drawing model (or as its native format). This makes possible some useful features, such as automatic generation of PDF files (you can save a screenshot "directly" to PDF), import of PDF data into native applications, rasterization of PDF data (including PostScript and EPS conversion), etc. There are Python bindings to the Quartz PDF engine. Note however, that Quartz's PDF support is not a replacement for, say, Adobe's professional level PDF tools.

Quartz also has an integrated hardware acceleration layer called Quartz Extreme that automatically becomes active on supported hardware.

The graphics environment also has other rendering libraries, for example, OpenGL (2D and 3D), QuickDraw (2D) and QuickTime.

The Application Services layer also includes various other component frameworks:

QuickTime is both a graphics environment and an application environment. It has excellent features for interactive multimedia that allow for manipulating, streaming, storing and enhancing video, sound, animation, graphics, text, music, and VR.

Application Environments

There are multiple execution environments on Mac OS X within which respective applications execute:

The fact that Mac OS X includes APIs and abstractions from so many different systems (Mach, *BSD, Mac OS 9, etc.) makes things rather confusing and messy sometimes. Consider that Mach uses tasks (that contain one or more threads), FreeBSD uses processes (with a proc structure, pid, etc.) while Carbon uses its own notion of processes in the Carbon Process Manager, with process serial numbers (PSNs) which are not the same as a BSD pid! If a process is running under the Classic virtualizer, then multiple Carbon Process Manager processes inside Classic are using one BSD process. Consider the following excerpt from the output of the ps command:

% ps -axw | grep Safari 345 ?? S 4:18.19 /Applications/Safari.app/Contents/\ MacOS/Safari -psn_0_917505

Safari is linked against both the Carbon and Cocoa frameworks, among others. The above output means that Unix process id 345 maps to Carbon Process Manager PSN 917505.

You can use the Carbon function GetProcessForPID(pid_t, ProcessSerialNumber *) to obtain the PSN for a process given its Unix pid (note that not all processes will have both).

Cocoa includes Java packages that let you create a Cocoa application using Java as the programming language. Moreover, Java programs can call Carbon and other frameworks via JNI.

Finally, although Java is considered an Application Environment, the Java subsystem can itself be represented as different layers above the kernel. The Java Virtual Machine along with core JDK packages is analogous to the Core Services layer, and so on (see picture).

Filesystem Hierarchy

Although Mac OS X has many directories similar to a traditional *nix system, such as /etc (a symbolic link to /private/etc, /usr, /tmp (a symbolic link to /private/tmp, etc., it has many others that are unique to it, for example:

/ root, the Local domain
/Applications GUI applications
/Applications/Utilities GUI utilities
/Developer Xcode developer tools
/Library User installed frameworks
/Network the Network domain
/System the System domain
/System/Library System frameworks
/Users Home directories, the User domain
~/Desktop Your desktop
~/DocumentsYour documents
~/Movies Your movies directory (iMovie uses it by default)
~/Music Your music directory (iTunes uses it by default)
~/Pictures Your pictures directory (iPhoto uses it by default)
~/Public For sharing (contents visible to others)
~/Sites Your www (apache) directory
<<< XNU: The Kernel main Mac OS X System Startup >>>