XNU ("X is Not Unix") is the computer
operating system
An operating system (OS) is system software that manages computer hardware and software resources, and provides common daemon (computing), services for computer programs.
Time-sharing operating systems scheduler (computing), schedule tasks for ...
(OS)
kernel developed at
Apple Inc.
Apple Inc. is an American multinational corporation and technology company headquartered in Cupertino, California, in Silicon Valley. It is best known for its consumer electronics, software, and services. Founded in 1976 as Apple Comput ...
since December 1996 for use in the Mac OS X (now
macOS
macOS, previously OS X and originally Mac OS X, is a Unix, Unix-based operating system developed and marketed by Apple Inc., Apple since 2001. It is the current operating system for Apple's Mac (computer), Mac computers. With ...
) operating system and released as
free and open-source software
Free and open-source software (FOSS) is software available under a license that grants users the right to use, modify, and distribute the software modified or not to everyone free of charge. FOSS is an inclusive umbrella term encompassing free ...
as part of the
Darwin OS, which, in addition to being the basis for macOS, is also the basis for
Apple TV Software,
iOS
Ios, Io or Nio (, ; ; locally Nios, Νιός) is a Greek island in the Cyclades group in the Aegean Sea. Ios is a hilly island with cliffs down to the sea on most sides. It is situated halfway between Naxos and Santorini. It is about long an ...
,
iPadOS
iPadOS is a mobile operating system developed by Apple for its iPad line of tablet computers. It was given a name distinct from iOS, the operating system used by Apple's iPhones to reflect the diverging features of the two product lines, suc ...
,
watchOS
watchOS is the operating system of the Apple Watch, developed by Apple Inc., Apple. It is based on iOS, the operating system used by the iPhone, and has many similar features. It was released on April 24, 2015, along with the Apple Watch, the o ...
,
visionOS
visionOS is a mixed reality operating system derived primarily from iPadOS and its core frameworks (including UIKit, SwiftUI, ARKit and RealityKit), and MR-specific frameworks for foveated rendering and real-time interaction. It was develope ...
, and
tvOS
tvOS (formerly Apple TV Software) is an operating system developed by Apple for the Apple TV, a digital media player. In the first-generation Apple TV, Apple TV Software was based on Mac OS X. The software for the second-generation and later ...
.
XNU was originally developed by
NeXT
NeXT, Inc. (later NeXT Computer, Inc. and NeXT Software, Inc.) was an American technology company headquartered in Redwood City, California that specialized in computer workstations for higher education and business markets, and later develope ...
for the
NeXTSTEP
NeXTSTEP is a discontinued object-oriented, multitasking operating system based on the Mach kernel and the UNIX-derived BSD. It was developed by NeXT, founded by Steve Jobs, in the late 1980s and early 1990s and was initially used for its ...
operating system. It was a
hybrid kernel
A hybrid kernel is an operating system Kernel (operating system), kernel whose architecture attempts to combine aspects and benefits of microkernel and monolithic kernel architectures used in operating systems.
Overview
The traditional kernel cat ...
derived from version 2.5 of the
Mach kernel
Mach () is an operating system kernel developed at Carnegie Mellon University by Richard Rashid and Avie Tevanian to support operating system research, primarily distributed and parallel computing. Mach is often considered one of the earliest ...
developed at
Carnegie Mellon University
Carnegie Mellon University (CMU) is a private research university in Pittsburgh, Pennsylvania, United States. The institution was established in 1900 by Andrew Carnegie as the Carnegie Technical Schools. In 1912, it became the Carnegie Institu ...
, which incorporated the bulk of the
4.3BSD kernel modified to run atop Mach primitives, along with an
application programming interface
An application programming interface (API) is a connection between computers or between computer programs. It is a type of software Interface (computing), interface, offering a service to other pieces of software. A document or standard that des ...
(API) in
Objective-C
Objective-C is a high-level general-purpose, object-oriented programming language that adds Smalltalk-style message passing (messaging) to the C programming language. Originally developed by Brad Cox and Tom Love in the early 1980s, it was ...
for writing drivers named DriverKit.
After Apple acquired NeXT, the kernel was updated with code derived from
OSFMK 7.3 from
OSF,
and the
FreeBSD
FreeBSD is a free-software Unix-like operating system descended from the Berkeley Software Distribution (BSD). The first version was released in 1993 developed from 386BSD, one of the first fully functional and free Unix clones on affordable ...
project, and the DriverKit was replaced with new API on a restricted subset of
C++ (based on
Embedded C++) named IOKit.
By keeping the BSD kernel into the third part of XNU, XNU became UNIX-based when macOS achieved UNIX certification under the Single UNIX Specification (SUS) by The Open Group. Despite this, Apple retained the original 'XNU' name, which stands for 'X is Not Unix,' a relic from its NeXTSTEP origins before macOS was UNIX-certified. This has led to confusion, as the name suggests that XNU is separate from UNIX, even though macOS, as a whole, is officially recognized as a UNIX operating system.
Kernel design
XNU is a
hybrid kernel
A hybrid kernel is an operating system Kernel (operating system), kernel whose architecture attempts to combine aspects and benefits of microkernel and monolithic kernel architectures used in operating systems.
Overview
The traditional kernel cat ...
, containing features of both
monolithic kernel
A monolithic kernel is an operating system software architecture, architecture with the entire operating system running in kernel space. The monolithic model differs from other architectures such as the microkernel in that it alone defines a high ...
s and
microkernel
In computer science, a microkernel (often abbreviated as μ-kernel) is the near-minimum amount of software that can provide the mechanisms needed to implement an operating system (OS). These mechanisms include low-level address space management, ...
s, attempting to make the best use of both technologies, such as the
message passing
In computer science, message passing is a technique for invoking behavior (i.e., running a program) on a computer. The invoking program sends a message to a process (which may be an actor or object) and relies on that process and its supporting ...
ability of microkernels enabling greater modularity and larger portions of the OS to benefit from
memory protection
Memory protection is a way to control memory access rights on a computer, and is a part of most modern instruction set architectures and operating systems. The main purpose of memory protection is to prevent a process from accessing memory that h ...
, and retaining the speed of monolithic kernels for some critical tasks.
, XNU runs on
ARM64
AArch64, also known as ARM64, is a 64-bit version of the ARM architecture family, a widely used set of computer processor designs. It was introduced in 2011 with the ARMv8 architecture and later became part of the ARMv9 series. AArch64 allows ...
and
x86-64
x86-64 (also known as x64, x86_64, AMD64, and Intel 64) is a 64-bit extension of the x86 instruction set architecture, instruction set. It was announced in 1999 and first available in the AMD Opteron family in 2003. It introduces two new ope ...
processors, both one processor and
symmetric multiprocessing
Symmetric multiprocessing or shared-memory multiprocessing (SMP) involves a multiprocessor computer hardware and software architecture where two or more identical processors are connected to a single, shared main memory, have full access to all ...
(SMP) models.
PowerPC
PowerPC (with the backronym Performance Optimization With Enhanced RISC – Performance Computing, sometimes abbreviated as PPC) is a reduced instruction set computer (RISC) instruction set architecture (ISA) created by the 1991 Apple Inc., App ...
support was removed as of the version in
Mac OS X Snow Leopard
Mac OS X Snow Leopard (version 10.6) (also referred to as OS X Snow Leopard) is the seventh major release of macOS, Apple's desktop and server operating system for Macintosh computers.
Snow Leopard was publicly unveiled on June 8, 2009, at A ...
. Support for
IA-32
IA-32 (short for "Intel Architecture, 32-bit", commonly called ''i386'') is the 32-bit version of the x86 instruction set architecture, designed by Intel and first implemented in the i386, 80386 microprocessor in 1985. IA-32 is the first incarn ...
was removed as of the version in
Mac OS X Lion; support for 32-bit ARM was removed as of the version in .
Mach
The basis of the XNU kernel is a heavily modified (hybrid)
Open Software Foundation
The Open Software Foundation, Inc. (OSF), was a not-for-profit industry consortium for creating an open standard for an implementation of the operating system Unix. It was formed in 1988 and merged with X/Open in 1996, to become The Open Group.
...
Mach kernel (
OSFMK) 7.3.
OSFMK 7.3 is a microkernel that includes applicable code from the
University of Utah
The University of Utah (the U, U of U, or simply Utah) is a public university, public research university in Salt Lake City, Utah, United States. It was established in 1850 as the University of Deseret (Book of Mormon), Deseret by the General A ...
Mach 4 kernel and from the many Mach 3.0 variants
forked from the original
Carnegie Mellon University
Carnegie Mellon University (CMU) is a private research university in Pittsburgh, Pennsylvania, United States. The institution was established in 1900 by Andrew Carnegie as the Carnegie Technical Schools. In 1912, it became the Carnegie Institu ...
Mach 3.0 microkernel.
OSFMK 7.3 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 kernel and that of the service daemons.
Apple licensed OSFMK 7.3 from the OSF, and attempted to streamline some tasks by building
BSD
The Berkeley Software Distribution (BSD), also known as Berkeley Unix or BSD Unix, is a discontinued Unix operating system developed and distributed by the Computer Systems Research Group (CSRG) at the University of California, Berkeley, beginni ...
functions into the kernel along with the Mach code. The result is a heavily modified (hybrid) OSFMK 7.3 kernel.
BSD
The
Berkeley Software Distribution
The Berkeley Software Distribution (BSD), also known as Berkeley Unix or BSD Unix, is a discontinued Unix operating system developed and distributed by the Computer Systems Research Group (CSRG) at the University of California, Berkeley, beginn ...
(BSD) part of the kernel provides the Portable Operating System Interface (
POSIX
The Portable Operating System Interface (POSIX; ) is a family of standards specified by the IEEE Computer Society for maintaining compatibility between operating systems. POSIX defines application programming interfaces (APIs), along with comm ...
)
application programming interface
An application programming interface (API) is a connection between computers or between computer programs. It is a type of software Interface (computing), interface, offering a service to other pieces of software. A document or standard that des ...
(API, BSD system calls), the
Unix
Unix (, ; trademarked as UNIX) is a family of multitasking, multi-user computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, a ...
process model atop Mach tasks, basic security policies, user and group ids, permissions, the network
protocol stack
The protocol stack or network stack is an implementation of a computer networking protocol suite or protocol family. Some of these terms are used interchangeably but strictly speaking, the ''suite'' is the definition of the communication protoc ...
(protocols), the
virtual file system
A virtual file system (VFS) or virtual filesystem switch is an abstract layer on top of a more concrete file system. The purpose of a VFS is to allow client applications to access different types of concrete file systems in a uniform way. A VFS ...
code (including a
file system independent
journaling layer), several local file systems such as
Hierarchical File System
In computing, a hierarchical file system is a file system that uses directories to organize files into a tree structure.
In a hierarchical file system, ''directories'' contain information about both files and other directories, called ''sub ...
(HFS,
HFS Plus
HFS Plus or HFS+ (also known as Mac OS Extended or HFS Extended) is a journaling file system developed by Apple Inc. It replaced the Hierarchical File System (HFS) as the primary file system of Apple computers with the 1998 release of Mac OS 8. ...
(HFS+)) and
Apple File System
Apple File System (APFS) is a Proprietary software, proprietary file system developed and deployed by Apple Inc. for macOS macOS Sierra, Sierra (10.12.4) and later, iOS iOS 10 , 10.3, tvOS 10.2, watchOS 3.2, and all versions of iPadOS. It aim ...
(APFS), the
Network File System
Network File System (NFS) is a distributed file system protocol originally developed by Sun Microsystems (Sun) in 1984, allowing a user on a client computer to access files over a computer network much like local storage is accessed. NFS, like ...
(NFS) client and server, cryptographic framework,
UNIX System V
Unix System V (pronounced: "System Five") is one of the first commercial versions of the Unix operating system. It was originally developed by AT&T and first released in 1983. Four major versions of System V were released, numbered 1, 2, 3, an ...
inter-process communication
In computer science, interprocess communication (IPC) is the sharing of data between running Process (computing), processes in a computer system. Mechanisms for IPC may be provided by an operating system. Applications which use IPC are often cat ...
(IPC), audit subsystem,
mandatory access control
In computer security, mandatory access control (MAC) refers to a type of access control by which a secured environment (e.g., an operating system or a database) constrains the ability of a ''subject'' or ''initiator'' to access or modify on an ' ...
, and some of the locking primitives. The BSD code present in XNU has been most recently synchronised with that from the
FreeBSD
FreeBSD is a free-software Unix-like operating system descended from the Berkeley Software Distribution (BSD). The first version was released in 1993 developed from 386BSD, one of the first fully functional and free Unix clones on affordable ...
kernel. Although much of it has been significantly modified, code sharing still occurs between Apple and the FreeBSD Project .
K32/K64
XNU in
Mac OS X Snow Leopard
Mac OS X Snow Leopard (version 10.6) (also referred to as OS X Snow Leopard) is the seventh major release of macOS, Apple's desktop and server operating system for Macintosh computers.
Snow Leopard was publicly unveiled on June 8, 2009, at A ...
, v10.6, (
Darwin version 10) comes in two varieties, a
32-bit
In computer architecture, 32-bit computing refers to computer systems with a processor, memory, and other major system components that operate on data in a maximum of 32- bit units. Compared to smaller bit widths, 32-bit computers can perform la ...
version called ''K32'' and a
64-bit
In computer architecture, 64-bit integers, memory addresses, or other data units are those that are 64 bits wide. Also, 64-bit central processing units (CPU) and arithmetic logic units (ALU) are those that are based on processor registers, a ...
version called ''K64''. K32 can run 64-bit applications in
userland. What was new in Mac OS X 10.6 was the ability to run XNU in 64-bit
kernel space
A modern computer operating system usually uses virtual memory to provide separate address spaces or regions of a single address space, called user space and kernel space. This separation primarily provides memory protection and hardware prote ...
. K32 was the default kernel for 10.6 ''Server'' when used on all machines except
Mac Pro
Mac Pro is a series of workstations and servers for professionals made by Apple Inc. since 2006. The Mac Pro, by some performance benchmarks, is the most powerful computer that Apple offers. It is one of four desktop computers in the current ...
and
Xserve
The Xserve is a discontinued series of rack-mounted servers that was manufactured by Apple Inc. between 2002 and 2011. It was Apple's first rack-mounted server, and could function as a file server, web server or run high-performance computing ...
models from 2008 onwards and can run 64-bit applications. K64 has several benefits compared to K32:
* Can manage more than 32 GB RAM, as the
memory map would consume a disproportionately large area of the 32-bit kernel space.
* Cache buffer sizes can be larger than what the 32-bit kernel space allows, potentially increasing I/O performance.
* Performance is increased when using high-performance networking devices or multiple
graphics processing unit
A graphics processing unit (GPU) is a specialized electronic circuit designed for digital image processing and to accelerate computer graphics, being present either as a discrete video card or embedded on motherboards, mobile phones, personal ...
s (GPUs), as the kernel can map all of the devices in 64-bit space even if several have very large
direct memory access
Direct memory access (DMA) is a feature of computer systems that allows certain hardware subsystems to access main system computer memory, memory independently of the central processing unit (CPU).
Without DMA, when the CPU is using programmed i ...
(DMA) buffers.
Booting while holding down ''6'' and ''4'' forces the machine to boot K64 on machines supporting 64-bit kernels. 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.
XNU in
OS X Mountain Lion
OS X Mountain Lion (version 10.8) is the ninth major release of macOS, Apple Inc.'s desktop and server operating system for Macintosh computers. OS X Mountain Lion was released on July 25, 2012, for purchase and download through the Mac App S ...
(10.8) and later only provides a 64-bit kernel.
IOKit
IOKit is the
device driver
In the context of an operating system, a device driver is a computer program that operates or controls a particular type of device that is attached to a computer or automaton. A driver provides a software interface to hardware devices, enabli ...
framework, written in a subset of
C++ based on
Embedded C++. Using its
object-oriented
Object-oriented programming (OOP) is a programming paradigm based on the concept of '' objects''. Objects can contain data (called fields, attributes or properties) and have actions they can perform (called procedures or methods and impleme ...
design, features common to any class of driver are provided within the framework, helping device drivers be written in less time and code. IOKit is multi-threaded,
symmetric multiprocessing
Symmetric multiprocessing or shared-memory multiprocessing (SMP) involves a multiprocessor computer hardware and software architecture where two or more identical processors are connected to a single, shared main memory, have full access to all ...
(SMP)-safe, and allows for hot-pluggable devices and automatic, dynamic device configuration.
Many drivers can be written to run in
user mode
A modern computer operating system usually uses virtual memory to provide separate address spaces or regions of a single address space, called user space and kernel space. This separation primarily provides memory protection and hardware prote ...
, which further enhances the stability of the system. If a driver running in user mode crashes, it will not crash the kernel. However, if a driver running in kernel mode crashes it will crash the kernel. Examples of drivers running in kernel mode include disk adapter and network adapter drivers, graphics drivers, drivers for Universal Serial Bus (
USB
Universal Serial Bus (USB) is an industry standard, developed by USB Implementers Forum (USB-IF), for digital data transmission and power delivery between many types of electronics. It specifies the architecture, in particular the physical ...
) and
FireWire
IEEE 1394 is an interface standard for a serial bus for high-speed communications and isochronous real-time data transfer. It was developed in the late 1980s and early 1990s by Apple in cooperation with a number of companies, primarily Sony a ...
host controllers, and drivers for
virtual machine
In computing, a virtual machine (VM) is the virtualization or emulator, emulation of a computer system. Virtual machines are based on computer architectures and provide the functionality of a physical computer. Their implementations may involve ...
software such as
VirtualBox
Oracle VirtualBox (formerly Sun VirtualBox, Sun xVM VirtualBox and InnoTek VirtualBox) is a hosted hypervisor for x86 virtualization developed by Oracle Corporation. VirtualBox was originally created by InnoTek Systemberatung GmbH, which was ac ...
,
Parallels Desktop for Mac, and
VMware Fusion
VMware Fusion is a software hypervisor developed by VMware for macOS systems. It allows Macs with Intel or Apple M series CPUs to run virtual machines with guest operating systems, such as Microsoft Windows, Linux, or macOS, within the host m ...
. In
macOS Catalina
macOS Catalina (version 10.15) is the sixteenth software versioning, major release of macOS, Apple Inc.'s desktop operating system for Macintosh computers. It is the successor to macOS Mojave and was announced at WWDC 2019 on June 3, 2019 and ...
and later releases, DriverKit allows some of those types of drivers to run in user mode.
See also
*
Kernel (operating system)
A kernel is a computer program at the core of a computer's operating system that always has complete control over everything in the system. The kernel is also responsible for preventing and mitigating conflicts between different processes. It is ...
*
A/UX
A/UX is a Unix-based operating system from Apple Computer for Macintosh computers, integrated with System 7's graphical interface and application compatibility. It is Apple's first official Unix-based operating system, launched in 1988 and disc ...
*
mkLinux
*
OSF/1
*
Darwin (operating system)
Darwin is the core Unix-like operating system of macOS, iOS, watchOS, tvOS, iPadOS, audioOS, visionOS, and bridgeOS. It previously existed as an independent open-source software, open-source operating system, first released by Apple Inc. in 20 ...
– open source operating system released by Apple, Inc., with XNU as kernel
*
macOS
macOS, previously OS X and originally Mac OS X, is a Unix, Unix-based operating system developed and marketed by Apple Inc., Apple since 2001. It is the current operating system for Apple's Mac (computer), Mac computers. With ...
– operating system released by Apple, Inc., with XNU as kernel
References
External links
* , official repository
* – an overview of the components of XNU, written by Amit Singh in December 2003
Inside the Mac OS X Kernel– "This talk intends to clear up the confusion by presenting details of the Mac OS X kernel" (December 2007)
{{DEFAULTSORT:Xnu
iOS
Mach (kernel)
Monolithic kernels
MacOS
Software using the Apple Public Source License