74
Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007

Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

Embed Size (px)

Citation preview

Page 1: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

Inside the Mac OS X Kernel

Debunking Mac OS Myths

lucy28 Dec 2007

Page 2: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

microkernel

Mach

FreeBSD

C++64 bit

Open Source

UNIX

Page 3: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

microkernel

Mach

FreeBSD

C++64 bit

Open Source

UNIX

On the Mac, this kernel is called Mach

Paul Thurrott, http://www.winsupersite.com/reviews/macosx_puma.asp

Page 4: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

microkernel

Mach

FreeBSD

C++64 bit

Open Source

UNIX

http://developer.apple.com/internet/

with its stable open-source core based on FreeBSD 5.0

Page 5: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

microkernel

Mach

FreeBSD

C++64 bit

Open Source

UNIXMac OS X for UNIX UsersThe power of UNIX with the simplicity of Macintosh.

FeaturesOpen source, UNIX-based foundation

• SMP-optimized kernel based on FreeBSD 5 and Mach 3.0

• 64-bit virtual memory based on the LP64 model

• Standard libraries and utilities for easy porting of Linux, UNIX, and POSIX source code

• Hand-tuned, standards-compliant scalar and vector math libraries

• UNIX GUI support via native toolkits and included X11 server

• Open source code available via the Darwin project

Standards-based networking• Complete IP-based architecture supporting

IPv4, IPv6, and L2TP/IPSec VPN • Rich zero-configuration discovery and naming

via Bonjour and Dynamic DNS• Interoperable file serving via NFS, AFP,

SMB/CIFS, and FTP • Powerful Apache services (httpd, DAV, PHP)• Open Directory services built on LDAP and

Kerberos for single sign-on

Comprehensive UNIX user environment• Standards-based graphics built on PDF

(Quartz), OpenGL, H.264, and MPEG-4 (QuickTime)

• Xterm-compliant Terminal integrated with Aqua user interface

• Choice of shells (bash, ksh, csh) and scripting languages (Perl, Python, Tcl, Ruby)

• Enhanced with Spotlight searching, Xgrid queuing, and Automator workflows

• Comprehensive UNIX/Linux utilities (emacs, vim, gnutar, make)

• Xcode 2 developer tools with GCC 4.0 for optimized code generation and ISO/IEC 14882:2003 C++ support

Technology BriefMac OS X for UNIX Users

Mac OS X version 10.4 Tiger combines a robust and open UNIX-based foundation with the richness and usability of the Mac interface, bringing UNIX technology and 64-bit power to the mass market. Apple has made open source and standards a key part of its strategy to deliver an industrial-strength operating system that is both innovative and easy to use.

There are over 15 million Mac OS X users—scientists, animators, developers, system administrators, and more—making Mac OS X the most widely used UNIX-based desktop operating system. In addition, Mac OS X is the only UNIX-based environment that natively runs Microsoft Office, Adobe Photoshop, and thousands of other consumer applications—all side by side with traditional command-line, X11, and Java applications. Mac OS X is also the foundation for Mac OS X Server, which makes open source software easy to administer. Tight integration with Apple hardware, from the sleek PowerBook G4 to the award-winning Xserve G5, is making Mac OS X the platform of choice for an emerging generation of UNIX users.

http://images.apple.com/macosx/pdf/MacOSX_UNIX_TB_v2.pdf

UNIX-based foundation

Page 6: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

microkernel

Mach

FreeBSD

C++64 bit

Open Source

UNIX

Steve Jobs, WWDC 2007

“Leopard is 64 bit top to bottom.”

Page 7: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

microkernel

Mach

FreeBSD

C++64 bit

Open Source

UNIX

Miles Nordin, http://www.linuxjournal.com/article/6105

Obsolete Microkernel Dooms Mac OS X to Lag Linux in Performance

Page 8: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

Mac OS

Macintosh

1985 1990 1995 2000

128 KBM68K3.5”

single tasking

Page 9: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

Macintosh

1985 1990 1995 2000

128 KBM68K3.5”

single tasking

System 7

PowerPCmultitasking

Page 10: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

Mac OS

Macintosh

1985 1990 1995 2000

128 KBM68K3.5”

single tasking

System 7

PowerPCmultitasking

Copland ?

Page 11: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

Jobs

Jobs

1985

Apple

NeXT

Page 12: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel
Page 13: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

Jobs

Jobs

1985

Gassée

1991

Gassée

Apple

NeXT

Be

Page 14: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel
Page 15: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

Jobs

Jobs

1985

Gassée

1991

Gassée

1996

?Apple

NeXT

Be

+ ?

Page 16: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

+

Jobs

Jobs

1985

Gassée

1991

Gassée

1996

JobsApple

NeXT

Be

Page 19: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

NEXTSTEP

NeXTNEXTSTEP 1.0

UNIX basepreemptive multitasking

memory protectionDisplay PostScript

68K

NEXTSTEP 3.1

i386PA-RISCSPARC Apple acquisition

RhapsodyPowerPC

Mac OS X 10.0

1985 1990 1995 2000 2005

i386

Page 20: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

XNU

Mach BSD I/O-Kit

X is not UNIX

Page 21: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

Monolithic Kernel

libc

kernel mode

user mode

App App App

hardware

MM schedHW IPC

VFS

API

secdev

net

Page 22: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

Microkernel

libc

kernel mode

user mode

App App App

hardware

MM schedHW IPC

VFS

API

secdev

net

Page 23: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

BSD Single Server

BSD

libc

kernel mode

user mode

App App App

hardware

MM schedHW IPC

VFS

API

secdev

net

Page 24: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

4

3

0

write();

user

kernel

write() {

}

monolithic

Page 25: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

ipc();

4

3

0

ipc();

user

kernel

ipc() {

}

microkernel

Page 26: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

ipc();

4

3

0

ipc();

user

kernel

ipc() {

}

microkernel

BSD

write() {

}

Page 27: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

ipc();

4

3

0

ipc();

user

kernel

ipc() {

}

microkernel

Page 28: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

BSD Single Server

MM schedHW IPC

VFS

API

secdev

libc

kernel mode

user mode

App App AppBSD

hardware

net

Page 29: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

Co-location

MM schedHW IPC

VFS

API

secdev

libc

kernel mode

user modeApp App AppBSD

hardware

net

Page 30: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

Mach

4

3

0

4

3

0

4

3

0

task task task4

0

RAM

ROM

VGA

I/OI/OI/O

• memory management

• scheduling

• inter-process communication

Page 31: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

Mach IPC4

3

0

4

3

0

Page 32: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

Mach Interface Generator (MIG)

4

3

0

4

3

0

main() { func(1,2,3);}

func(a,b,c) {

}

MIGgenerated

code

func(a,b,c) { msg.a = a; msg.b = b; msg.c = c; send(msg);}

receive(msg);a = msg.a;b = msg.b;c = msg.c;func(a,b,c);

Page 33: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

signalPOSIXthread

process

Mach + BSD

task thread exceptionMach

BSD

schedulerMM IPC

VFS BSD sockets

/dev

syscalls

int/exc

kerneluser

fork() open() ...

mach message

syscalls

int 0x80

%eax>0 <0

Page 34: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

Drivers

driver.c driver2.c

Page 35: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

Drivers

driver.c

#ifdef

#ifdef

#ifdef#ifdef

#ifdef

Page 36: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

I/O-Kit

special.ccgeneric.cc

Page 37: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel
Page 38: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel
Page 39: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"><dict> <key>CFBundleDevelopmentRegion</key> <string>English</string> <key>CFBundleExecutable</key> <string>msdosfs</string> <key>CFBundleIdentifier</key> <string>com.apple.filesystems.msdosfs</string> <key>CFBundleInfoDictionaryVersion</key> <string>6.0</string> <key>CFBundleName</key> <string>msdosfs</string> <key>CFBundlePackageType</key> <string>KEXT</string> <key>CFBundleShortVersionString</key> <string>1.5</string> <key>CFBundleSignature</key> <string>????</string> <key>CFBundleVersion</key> <string>1.5</string> <key>IOKitPersonalities</key> <dict/> <key>OSBundleLibraries</key> <dict> <key>com.apple.kpi.bsd</key> <string>8.0.0</string> <key>com.apple.kpi.libkern</key> <string>9.0.0d3</string> <key>com.apple.kpi.mach</key> <string>8.0.0</string> <key>com.apple.kpi.unsupported</key> <string>8.0.0</string> </dict></dict></plist>

Info.plist

<key>OSBundleLibraries</key> <dict> <key>com.apple.kpi.bsd</key> <string>8.0.0</string> <key>com.apple.kpi.libkern</key> <string>9.0.0d3</string> <key>com.apple.kpi.mach</key> <string>8.0.0</string> <key>com.apple.kpi.unsupported</key> <string>8.0.0</string> </dict>

Page 40: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

BootingPC/BIOS

MBR

?

BIOS

640KBRAM

Video

1 MB

0 MB

Page 41: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

BootingEFI

GPT EFI

2 GBRAM

Video

4 GB

0 GB

HFS+

HFS+

/System/LibraryCoreServices/boot.efiCaches/com.apple.kernelcaches/Extensions

mach_kernel

Page 43: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

libSystem.dylib: Mach-O universal binary with 4 architectures

Mach-O$ file libSystem.dylib

libSystem.dylib (for architecture ppc7400): Mach-O dynamically linked shared library ppclibSystem.dylib (for architecture ppc64): Mach-O 64-bit dynamically linked shared library ppc64libSystem.dylib (for architecture i386): Mach-O dynamically linked shared library i386libSystem.dylib (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64

/usr/lib/usr/lib64

C:\WINDOWS\SYSTEMC:\WINDOWS\SYSTEM32C:\WINDOWS\SYSTEM64

/mach_kernel: Mach-O universal binary with 2 architectures/mach_kernel (for architecture i386): Mach-O executable i386/mach_kernel (for architecture ppc): Mach-O executable ppc

$ file /mach_kernel

Page 44: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

Rosetta

hardware

XNU

userkernel

libSystem

libA libB libC

ppci386

hardware

XNU

libSystem

libB

PowerPC app

libC

Rosetta (byte swapping)

Rosetta (byte swapping)

PowerPC app

libA

Rosetta (dynarec)

Rose

tta

(dyn

arec

)

Page 45: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

Architectures

i386

i386PA-RISCSPARC

PowerPC(i386)68K

1990 1995 2000 2005

Page 46: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

3/1 Splitkernel

user

Windows, Linux, ...

4 GB

3 GB

0 GB

useruseruser

Page 47: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

userkerneluserkernel

4/4 Split

Mac OS X Intel

4 GB

0 GB

switcher

Page 48: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

userkerneluser

4/4 Split

Mac OS X Intel

4 GB

0 GB

switcher

Page 49: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

x86_64

kernel

intr handler2^47

04 GB userkernelkernel

Page 50: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

x86_64

kernel

intr handler2^47

04 GB user

Page 51: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

x86_64

user

intr handler2^47

04 GB

Page 52: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

iPhone

• ARM

• Custom Bootloader

• No real KEXTs

• Kernel Cache

Page 53: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel
Page 54: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel
Page 55: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel
Page 56: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel
Page 57: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

What Makes XNU Great

Page 58: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

What Makes XNU Great

#8dtrace

Page 59: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

What Makes XNU Great

#7kernel cache

Page 60: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

What Makes XNU Great

#6Separation between Mach, BSD, I/O-Kit

Page 61: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

What Makes XNU Great

#5POSIX Conformance

Page 62: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

What Makes XNU Great

#4Mach Message API

Page 63: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

What Makes XNU Great

#3I/O-Kit

Page 64: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

What Makes XNU Great

#2Stable KEXT ABI

Page 65: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

What Makes XNU Great

#1Universal Binaries

Page 66: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

Buzzwordsagain

Page 67: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

Mach

• The Mac OS X kernel is not “Mach”.

• The Mac OS X kernel is XNU.

• XNU consists of Mach, BSD and I/O-Kit.

Page 68: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

Microkernel

• The OS X kernel is not a microkernel.

• The Mach codebase can be used as a microkernel.

• XNU is a monolithic kernel.

• BSD and most drivers are in kernel mode.

Page 69: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

FreeBSD Kernel

• The Mac OS X kernel is not based on the FreeBSD kernel.

• XNU contains some FreeBSD code.

Page 70: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

C++

• XNU is not written in C++.

• I/O-Kit is written in Embedded C++.

• Mach and BSD are written in C.

Page 71: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

64 bit

• The Mac OS X kernel is not 64 bit.

• It supports 64 bit user land applications.

• The kernel code is 32 bit with tiny 64 bit parts for user support.

Page 72: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

Open Source

• The Mac OS X kernel and most of the UNIX bits are Open Source.

• But there is no live repository.

• Some code is missing.

• But it can be compiled into a working system.

Page 73: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

• Mac OS X is “UNIX”.

• But only since Leopard.

• It passed the POSIX Conformance Test.

• It may use the “UNIX” trademark.

• It does not contain AT&T UNIX code.

Page 74: Inside the Mac OS X Kernel - events.ccc.de · Inside the Mac OS X Kernel Debunking Mac OS Myths lucy 28 Dec 2007. microkernel Mach FreeBSD C++ 64 bit Open Source UNIX. microkernel

Awesome

• But Mac OS X is awesome.

• That’s a fact.

lucy