What is Mac OS X?
Above the Kernel
This page discusses the software layers above the kernel in Mac OS X.
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):
- CarbonCore: Core parts of Carbon, such as various Carbon managers. Carbon has traditionally been a very critical Mac OS API family, and is so in Mac OS X as well.
- CFNetwork: An API for user-level networking that includes several protocols such as FTP, HTTP, LDAP, SMTP, ...
- OSServices: A framework that includes various system APIs (accessing disk partitions, the system keychain, Open Transport, sound, power, etc.)
- SearchKit: A framework for indexing and searching text in multiple languages.
- WebServicesCore: APIs for using Web Services via SOAP and XML-RPC.
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:
- Quartz Compositor: consists of the window server (the
WindowServerprogram) and some private libraries. Quartz implements a layered compositing engine, in which every pixel on a screen can be shared between different windows in real time. - Quartz 2D: a 2D graphics rendering library.
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:
- Apple Events: a mechanism for inter-application communication.
- Apple Type Services: a framework for managing and accessing fonts on Mac OS X.
- ColorSync: Apple's color management system that's integrated with Mac OS X.
- CoreGraphics: a graphics framework that's used for implementing Quartz.
- FindByContent: an API that allows searching specific volumes or folders for files containing the specified content.
- HIServices: framework providing human-interface related services, such as for icon management, translation, "pasteboard" (clipboard) etc.
- LangAnalysis: an API to the Language Analysis Manager, allows for analyzing morphemes (a morpheme is a meaningful linguistic unit, that is, a distinctive collocation of phonemes, having no smaller meaningful parts) in text.
- LaunchServices: a medium-level interface to starting applications, including opening documents with either a specified or the default application, open URLs, etc.
- PrintCore: an API to the printing subsystem.
- QD: a 2D graphics engine.
- SpeechSynthesis: an API for generating synthesized speech.
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:
- BSD: This application environment is similar to a traditional *BSD system and provides a BSD-based POSIX API. It consists of a BSD runtime and execution environment. Mac OS X uses FreeBSD as a reference code base for its BSD derivations (Panther derives from FreeBSD 5.0). The libraries and headers for this environment reside in their traditional location (
/usr/liband/usr/include, respectively). - Carbon: This is a set of procedural C-based APIs for Mac OS X that are based on the "old" Mac OS 9 APIs. Note that Carbon does not include all the old APIs - a subset of the old APIs has been modified to work with OS X. Some APIs have been dropped as they are not applicable any more because of the radical differences between Mac OS X and Mac OS 9.
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).
- Classic: This is a compatibility environment so that Mac OS 9 applications can be run on Mac OS X. The Classic application is technically a virtualizer that runs in a protected memory environment, with multiple processes in Mac OS 9 layered on top of one BSD process.
- Cocoa: This is an object-oriented API for developing applications written in Objective-C and Java. Cocoa is an important inheritance from NEXTSTEP (a fact testified by the various
NS*names in its API). It is very well supported by Apple's rapid development tools, and is the preferred way of doing things on Mac OS X if what you want to do can be done through Cocoa. There are many parts of Mac OS X that have not "converted" to Cocoa completely, or at all. A Cocoa application can call the Carbon API. Cocoa is largely based on the OpenStep frameworks, and consists of primarily two parts: the Foundation (fundamental classes) and the Application Kit (classes for GUI elements). - Java: This environment consists of a JDK, both command-line and integrated with Apple's IDE, a runtime (Hotspot VM, JIT), and various Java classes (AWT, Swing, ...).
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 |
~/Documents | Your 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 |