![Part I For Power Users Chapter 1 Darwinism The Evolution of OS X Chapter 2 - photo 1](/uploads/posts/book/56440/images/cover_fmt.jpg)
Part I
For Power Users
Chapter 1: Darwinism: The Evolution of OS X
Chapter 2: E Pluribus Unum: Architecture of OS X and iOS
Chapter 3: On the Shoulders of Giants: OS X and iOS Technologies
Chapter 4: Parts of the Process: Mach-O, Process, and Thread Internals
Chapter 5: Non Sequitur: Process Tracing and Debugging
Chapter 6: Alone in the Dark: The Boot Process: EFI and iBoot
Chapter 7: The Alpha and the Omega launchd
Chapter 1
Darwinism: The Evolution of OS X
Mac OS has evolved tremendously since its inception. From a niche operating system of a cult crowd, it has slowly but surely gained mainstream share, with the recent years showing an explosion in popularity as Macbooks, Macbook Pros, and Airs become ever more ubiquitous, clawing back market share from the gradually declining PC. Its mobile derivative iOS is by some accounts the mobile operating system with the largest market share, head-to-head with Linux's derivative, Android.
The growth, however, did not happen overnight. In fact, it was a long and excruciating process, which saw Mac OS come close to extinction, before it was reborn as OS X. Simply reborn is an understatement, as Mac OS underwent a total reincarnation, with its architecture torn down and rebuilt anew. Even then, Mac OS still faced significant hardship before the big breakthrough which came with Apple's transition to Intel-based architecture, leaving behind its long history with PowerPC architectures.
The latest and greatest version, OS X 10.7, or Lion, occurred shortly before the release of this book, as did the release of iOS 5.x, the most recent version of iOS. To understand their features and the relationship between the two, however, it makes sense to take a few steps back and understand how the architecture unifying both came to be.
The following is by no means a complete listing of features, but rather a high-level perspective. Apple has been known to add hundreds of features between releases, mostly in GUI and application support frameworks. Rather, more emphasis is placed on design and engineering features. For a comprehensive treatise on Mac OS versions to date, see Amit Singh's work on the subject[1], or check Ars Technica's comprehensive reviews[2]. Wikipedia also maintains a fairly complete list of changes[3].
The Pre-Darwin Era: Mac OS Classic
Mac OS Classic is the name given the pre-OS X era of Mac OS. The operating system then was nothing much to boast about. True, it was novel in that it was an all-GUI system (earlier versions did not have a command line like today's Terminal app). Memory management was poor, however, and multitasking was cooperative, which by today's standards is considered primitive. Cooperative multitasking involves processes voluntarily yielding their CPU timeslice, and works reasonably well when processes are well behaved. If even one process refuses to cooperate, however, the entire system screeches to a halt. Nonetheless, Mac OS Classic laid some of the foundations for the contemporary Mac OS, or OS X. Primarily, those foundations include the Finder GUI, and the file system support for forks in the first generation HFS file system. These affect OS X to this very day.
The Prodigal Son: NeXTSTEP
While Mac OS experienced its growing pains in the face of the gargantuan PC, its founder Steve Jobs left Apple (by some accounts was ousted) to get busy with a new and radically different company. The company, NeXT, manufactured specialized hardware, the NeXT computer and NeXTstation, with a dedicated operating system called NeXTSTEP.
NeXTSTEP boasted some avant-garde features for the time:
- NeXTSTEP was based on the Mach microkernel, a little-known kernel developed by Carnegie Mellon University (CMU). The concept of a microkernel was, itself, considered a novelty, and remains rarely implemented even today.
- The development language used was Objective-C, a superset of C, which unlike C++ is heavily object-oriented.
- The same object-orientation was prevalent all throughout the operating system. The system offered frameworks and kits, which allowed for rapid GUI development using a rich object library, based on the NSObject .
- The device driver environment was an object-oriented framework as well, known as DriverKit. Drivers could subclass other drivers, inheriting from them and extending their functionality.
- Applications and libraries were distributed in self-contained bundles. Bundles consisted of a fixed directory structure, which was used to package software, along with its dependencies and related files, so installing and uninstalling could be as easy as moving around a folder.
- PostScript was heavily used in the system, including a variant called display postscript, which enabled the rendering of display images as postscript. Printing support was thus 1:1, unlike other operating systems, which needed to convert to a printer-friendly format.
NeXTSTEP went down the road of better operating systems (remember OS/2?), and is nowadays extinct, save for a GNUStep port. Yet, its legacy lives on to the present day. One winter day in 1997, Apple with an OS that wasn't going anywhere ended up acquiring NeXT, bringing its intellectual property into Apple, along with Steve Jobs. And the rest, as they say, is history.
Enter: OS X
As a result of the acquisition of NeXT, Apple gained access to Mach, Objective-C, and the other aspects of the NeXTSTEP architecture. While NeXTSTEP was discontinued as a result, these components live on in OS X. In fact, OS X can be considered as a fusion of Mac OS Classic and NeXTSTEP, mostly the latter absorbing the former. The transition wasn't immediate, and Mac OS passed through an interim operating system called Rhapsody, which never really went public. It was Rhapsody, however, that eventually evolved into the first version of Mac OS X, and its kernel became the core of what is now known as Darwin.
Mac OS X is closer in its design and implementation to NeXTSTEP than it is to any other operating system, including Apple's own OS 9. As you will see, the core components of OS X Cocoa, Mach, IOKit, the XCode Interface Builder, and others are all direct descendants of NeXTSTEP. The fusion of two fringe, niche operating systems one with a great GUI and poor design, the other with great design but lackluster GUI resulted in a new OS that has become far more popular than the both of them combined.
OS X vs. Darwin
There is sometimes some confusion between OS X and Darwin regarding the definitions of the two terms, and the relationship between them. Let's attempt to clarify this:
OS X is the name given, collectively, to the entire operating system. As discussed in the next chapter, the operating system contains many components, of which Darwin is but one.
Darwin is the UNIX-like core of the operating system, which is itself comprised of the kernel, XNU (an acronym meaning X is Not UNIX, similar to GNU's recursive acronym) and the runtime. Darwin is open source (save for its adaptation to ARM in iOS, discussed later), whereas other parts of OS X Apple's frameworks are not.
There exists a straightforward correlation between the version of OS X and the version of Darwin. With the exception of OS X 10.0, which utilized Darwin 1.3. x, all other versions follow a simple equation:
If (OSX.version == 10.x.y) Darwin.version = (4+x).y
So, for example, the upcoming Mountain Lion, being 10.8.0, is Darwin 12.0. The last release of Snow Leopard, 10.6.8, is Darwin 10.8. It's a little bit confusing, but at least it's consistent.
Next page