Wednesday, February 6, 2008

X is not UNIX

xnu is the name of the kernel of Mac OS X (Darwin). It is unofficially an acronym for "X is Not UNIX". It is also a coincidental tribute to the fact that it is indeed the NuKernel for Mac OS X. xnu can be viewed as having a Mach-base core (Mach 3), a BSD-based (FreeBSD 5) operating system personality, and an object-oriented runtime environment for drives and other kernel extensions.

A running kernel contains numerous drivers that do not reside in the xnu code base but have their own Darwin packages. Darwin xnu package consists of about million lines of code, of which half could be categorized under BSD and a third under Mach, form the low-level foundation of OS X. The sources for Darwin (version 2.0) under the Apple Public Source License (APSL) was classified as a free software license by the Free Software Foundation (FSF). The rest of the packages are provided under their respective licenses, such as the GNU General Public License (GPL), the BSD License, the Carnegie Mellon University License and so on. There are about 350 packages in Darwin 8.6 (PPC) for Mac OS X 10.4.6. Darwin does not include the proprietary components that are integrated as parts of OS X, i.e. the Aqua, Carbon, Cocoa, OpenGL, Quartz and QuickTime, etc. Although it lacks the visual technologies of OS X, it supports graphical X11 Window System. We can divide Mac OS X kernel into the following components:
  • Mach - the service layer
  • BSD - the primary system programming interface provider
  • I/O Kit - the runtime environment for drivers
  • libkern - an in-kernel library
  • libsa - an in-kernel library that is normally used only during the system startup
  • Platform Expert - the hardware abstraction module (platform-specific)
  • Kernel Extensions - various I/O Kit families, the majority of loadable device drivers, and some non-I/O Kit extensions.
The number of kernel extensions loaded at any time on a given system can be read by the kextstat command. The /System/Library/Extensions directory is the standard location of kernel extensions.