XNU

XNU kernel
Developer Apple Inc.
Written in C, C++
OS family Unix-like
Working state Current
Source model Open-source
Initial release December 1996 (1996-12)
Available in English, others
Platforms IA-32, x86-64, ARM
Kernel type Hybrid
License Apple Public Source License 2.0
Official website opensource.apple.com/source/xnu

XNU is the computer operating system kernel developed at Apple Inc. since December 1996 for use in the macOS operating system and released as free and open-source software as part of the Darwin operating system. It is also used as the kernel for the iOS, tvOS, and watchOS operating systems. XNU is an abbreviation of X is Not Unix.[1]

Originally developed by NeXT for the NeXTSTEP operating system, XNU was a hybrid kernel combining version 2.5 of the Mach kernel developed at Carnegie Mellon University with components from 4.3BSD and an Objective-C API for writing drivers called Driver Kit.

After Apple acquired NeXT, the Mach component was upgraded to 3.0, the BSD components were upgraded with code from the FreeBSD project, and the Driver Kit was replaced with a C++ API for writing drivers called I/O Kit.

Kernel design

XNU is a hybrid kernel, containing features of both monolithic kernels and microkernels, attempting to make the best use of both technologies, such as the message passing ability of microkernels enabling greater modularity and larger portions of the OS to benefit from memory protection, and retaining the speed of monolithic kernels for some critical tasks.

As of 2007, XNU runs on ARM,[2] IA-32, and x86-64 processors, both one processor and symmetric multiprocessing (SMP) models. PowerPC support is removed as of version 10 (i.e., Mac OS X 10.6).

Mach

The basis of the XNU kernel, Mach, is a heavily modified "hybrid" mach 3.0 kernel. As such, it is able to run the core of an operating system as separated processes, which allows a great flexibility (it could run several operating systems in parallel above the Mach core), but this often reduces performance because of time consuming kernel/user mode context switches and overhead stemming from mapping or copying messages between the address spaces of the hybrid kernel and that of the service daemons. With Mac OS X, the designers have attempted to streamline some tasks and thus BSD functionality was built into the core with Mach. The result is a combination of a heavily modified "hybrid" mach 3.0 kernel and a classic BSD kernel, with some advantages and disadvantages of both.

BSD

The Berkeley Software Distribution (BSD) part of the kernel provides the POSIX application programming interface (API, BSD system calls), the Unix process model atop Mach tasks, basic security policies, user and group ids, permissions, the networking protocols, the virtual file system code (including a filesystem independent journaling layer), several local file systems such as HFS/HFS+, the Network File System (NFS) client and server, cryptographic framework, UNIX System V inter-process communication (IPC), audit subsystem, mandatory access control, and some of the locking primitives.[3] The BSD code present in XNU came from the FreeBSD kernel. Although much of it has been significantly modified, code sharing still occurs between Apple and the FreeBSD Project.[4]

K32/K64

XNU in Mac OS X Snow Leopard, v10.6, (Darwin version 10) and later comes in two varieties, a 32-bit version called K32 and a 64-bit version called K64.[5] K32 can run 64-bit applications in userland. What's new in Mac OS X 10.6 is the ability to run XNU in 64-bit kernel space. K32 is the default kernel for 10.6 Server when used on all machines except newer Mac Pro and Xserve models (2008 and later)[6] and can run 64-bit applications. K64 has several benefits compared to K32:[7]

Booting while holding down 6 and 4 forces the machine to boot K64 on machines supporting 64-bit kernels.[8] K64 will run 32-bit applications but it will not run 32-bit kernel extensions (KEXTs) so these must be ported to K64 to be able to load.

I/O Kit

I/O Kit is the device driver framework, written in a subset of C++ based on Embedded C++.[9] Using its object-oriented design, features common to any class of driver are provided within the framework, helping device drivers be written in less time and code. The I/O Kit is multi-threaded, symmetric multiprocessing (SMP)-safe, and allows for hot-pluggable devices and automatic, dynamic device configuration.

Many drivers can be written to run from user space, which further enhances the stability of the system. If a user-space driver crashes, it will not crash the kernel. However, if a kernel-space driver crashes it will crash the kernel. Examples of kernel-space drivers include disk adapter and network adapter drivers, graphics drivers, drivers for Universal Serial Bus (USB) and FireWire host controllers, and drivers for virtual machine software such as VirtualBox, Parallels Desktop for Mac, and VMware Fusion.

Protecting shared resources

In order to run safely on multiprocessor machines, access to shared resources (files, data structures etc.) must be serialized so that threads or processes do not attempt to modify the same resource at the same time. Atomic operations, spinlocks, critical sections, mutual exclusions ("mutexes"), and serializing tokens are all possible methods that can be used to prevent concurrent access. Like recent versions of Linux and FreeBSD, XNU, as of Mac OS X 10.4 and Darwin 8.0, employs a fine-grained mutex model to achieve higher performance on multiprocessor systems.

See also

References

External links

This article is issued from Wikipedia - version of the 11/3/2016. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.