Академический Документы
Профессиональный Документы
Культура Документы
Kernel
Debunking Mac OS Myths
lucy
28 Dec 2007
microkernel
Mach
FreeBSD
C++
64 bit
Open Source
UNIX
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
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
microkernel
Mach
FreeBSD
C++
64 bit
Open Source
UNIX
!"# %& ' ()* +,-' +./*.
!"# %&'#( &) *+,- './" /"# 0.1%2.3./4 &) 563.7/&0"8
9#6/:(#0
!"#$ &'()*#+ ,-./012 4'($3256'$
; <5=>&%/.1.?#@ A#(7#2 B60#@ &7 9(##C<D E
67@ 563" F8G
; HI>B./ J.(/:62 1#1&(4 B60#@ &7 /"# K=HI
1&@#2
; </67@6(@ 2.B(6(.#0 67@ :/.2./.#0 )&( #604 %&(/.7L
&) K.7:MN *+,-N 67@ =O<,- 0&:(3# 3&@#
; P67@>/:7#@N 0/67@6(@0>3&1%2.67/ 03626( 67@
J#3/&( 16/" 2.B(6(.#0
; *+,- Q*, 0:%%&(/ J.6 76/.J# /&&2A./0 67@
.732:@#@ -RR 0#(J#(
; O%#7 0&:(3# 3&@# 6J6.26B2# J.6 /"# D6('.7
%(&S#3/
752$32)3&012 $#58')96$:
; T&1%2#/# ,=>B60#@ 6(3"./#3/:(# 0:%%&(/.7L
,=JIN ,=JHN 67@ KU!=V,=<#3 W=+
; X.3" ?#(&>3&7).L:(6/.&7 @.03&J#(4 67@ 761.7L
J.6 C&7S&:( 67@ D4761.3 D+<
; ,7/#(&%#(6B2# ).2# 0#(J.7L J.6 +9<N Y9=N
<5CVT,9<N 67@ 9!=
; =&'#():2 Y%63"# 0#(J.3#0 Z"//%@N DYWN =P=[
; O%#7 D.(#3/&(4 0#(J.3#0 B:.2/ &7 KDY= 67@
\#(B#(&0 )&( 0.7L2# 0.L7>&7
;'<")#=#$&6># ,-./ (&#) #$>6)'$<#$5
; </67@6(@0>B60#@ L(6%".30 B:.2/ &7 =D9
Z]:6(/?[N O%#7QKN P8UHIN 67@ 5=^Q>I
Z]:.3A!.1#[
; -/#(1>3&1%2.67/ !#(1.762 .7/#L(6/#@ './"
Y_:6 :0#( .7/#()63#
; T"&.3# &) 0"#220 ZB60"N A0"N 30"[ 67@ 03(.%/.7L
267L:6L#0 Z=#(2N =4/"&7N !32N X:B4[
; ^7"673#@ './" <%&/2.L"/ 0#6(3".7LN -L(.@
_:#:.7LN 67@ Y:/&16/&( '&(A)2&'0
; T&1%(#"#70.J# *+,-VK.7:M :/.2./.#0 Z#1630N
J.1N L7:/6(N 16A#[
; -3&@# U @#J#2&%#( /&&20 './" QTT I8G )&(
&%/.1.?#@ 3&@# L#7#(6/.&7 67@ ,<OV,^T
RI``UaUGGF Tbb 0:%%&(/
?#*=$'@':A B)6#4
563 O< - )&( *+,- *0#(0
563 O< - J#(0.&7 RG8I !.L#( 3&1B.7#0 6 (&B:0/ 67@ &%#7 *+,->B60#@ )&:7@6/.&7
'./" /"# (.3"7#00 67@ :06B.2./4 &) /"# 563 .7/#()63#N B(.7L.7L *+,- /#3"7&2&L4 67@
HI>B./ %&'#( /& /"# 1600 16(A#/8 Y%%2# "60 16@# &%#7 0&:(3# 67@ 0/67@6(@0 6 A#4
%6(/ &) ./0 0/(6/#L4 /& @#2.J#( 67 .7@:0/(.62>0/(#7L/" &%#(6/.7L 040/#1 /"6/ .0 B&/"
.77&J6/.J# 67@ #604 /& :0#8
!"#(# 6(# &J#( RE 1.22.&7 563 O< - :0#(0c03.#7/.0/0N 67.16/&(0N @#J#2&%#(0N 040/#1
6@1.7.0/(6/&(0N 67@ 1&(#c16A.7L 563 O< - /"# 1&0/ '.@#24 :0#@ *+,->B60#@
@#0A/&% &%#(6/.7L 040/#18 ,7 6@@./.&7N 563 O< - .0 /"# &724 *+,->B60#@ #7J.(&71#7/
/"6/ 76/.J#24 (:70 5.3(&0&)/ O)).3#N Y@&B# ="&/&0"&%N 67@ /"&:067@0 &) &/"#( 3&70:1#(
6%%2.36/.&70c622 0.@# B4 0.@# './" /(6@./.&762 3&1167@>2.7#N -RRN 67@ d6J6 6%%2.36/.&708
563 O< - .0 620& /"# )&:7@6/.&7 )&( 563 O< - <#(J#(N '".3" 16A#0 &%#7 0&:(3# 0&)/'6(#
#604 /& 6@1.7.0/#(8 !.L"/ .7/#L(6/.&7 './" Y%%2# "6(@'6(#N )(&1 /"# 02##A =&'#(C&&A
QI /& /"# 6'6(@>'.77.7L -0#(J# QEN .0 16A.7L 563 O< - /"# %26/)&(1 &) 3"&.3# )&( 67
#1#(L.7L L#7#(6/.&7 &) *+,- :0#(08
http://images.apple.com/macosx/pdf/MacOSX_UNIX_TB_v2.pdf
UNIX-based foundation
microkernel
Mach
FreeBSD
C++
64 bit
Open Source
UNIX
Steve Jobs, WWDC 2007
Leopard is 64 bit top to bottom.
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
Mac OS
Macintosh
1985 1990 1995 2000
128 KB
M68K
3.5
single tasking
Macintosh
1985 1990 1995 2000
128 KB
M68K
3.5
single tasking
System 7
PowerPC
multitasking
Mac OS
Macintosh
1985 1990 1995 2000
128 KB
M68K
3.5
single tasking
System 7
PowerPC
multitasking
Copland
?
Jobs
Jobs
1985
Apple
NeXT
Jobs
Jobs
1985
Gasse
1991
Gasse
Apple
NeXT
Be
Jobs
Jobs
1985
Gasse
1991
Gasse
1996
?
Apple
NeXT
Be
+ ?
+
Jobs
Jobs
1985
Gasse
1991
Gasse
1996
Jobs Apple
NeXT
Be
http://www.hawkwings.net/wp-content/uploads/2006/07/stevesellsNeXT.jpg
http://www.photonhunter.co.uk/~art/computers/nextscreenshot.gif
NEXTSTEP
NeXT
NEXTSTEP 1.0
UNIX base
preemptive multitasking
memory protection
Display PostScript
68K
NEXTSTEP 3.1
i386
PA-RISC
SPARC
Apple acquisition
Rhapsody
PowerPC
Mac OS X 10.0
1985 1990 1995 2000 2005
i386
XNU
Mach BSD I/O-Kit
X is not UNIX
Monolithic Kernel
libc
kernel mode
user mode
App App App
hardware
MM sched HW IPC
VFS
API
sec
dev
net
Microkernel
libc
kernel mode
user mode
App App App
hardware
MM sched HW IPC
VFS
API
sec
dev
net
BSD Single Server
B
S
D
libc
kernel mode
user mode
App App App
hardware
MM sched HW IPC
VFS
API
sec
dev
net
4
3
0
write();
user
kernel
write() {
}
monolithic
ipc();
4
3
0
ipc();
user
kernel
ipc() {
}
microkernel
ipc();
4
3
0
ipc();
user
kernel
ipc() {
}
microkernel
BSD
write() {
}
ipc();
4
3
0
ipc();
user
kernel
ipc() {
}
microkernel
BSD Single Server
MM sched HW IPC
VFS
API
sec
dev
libc
kernel mode
user mode
App App App
B
S
D
hardware
net
Co-location
MM sched HW IPC
VFS
API
sec
dev
libc
kernel mode
user mode
App App App
B
S
D
hardware
net
Mach
4
3
0
4
3
0
4
3
0
task task task
4
0
RAM
ROM
VGA
I/O
I/O
I/O
memory
management
scheduling
inter-process
communication
Mach IPC
4
3
0
4
3
0
Mach Interface
Generator (MIG)
4
3
0
4
3
0
main() {
func(1,2,3);
}
func(a,b,c) {
}
MIG
generated
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);
signal
POSIX
thread
process
Mach + BSD
task thread exception
Mach
BSD
scheduler MM
IPC
VFS
BSD
sockets
/dev
syscalls
int/exc
kernel
user
fork() open() ...
mach
message
syscalls
int 0x80
%eax
>0 <0
Drivers
driver.c driver2.c
Drivers
driver.c
#ifdef
#ifdef
#ifdef
#ifdef
#ifdef
I/O-Kit
special.cc generic.cc
<?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>CFBundleIdentier</key>
<string>com.apple.lesystems.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>
Booting
PC/BIOS
MBR
?
BIOS
640KB
RAM
Video
1 MB
0 MB
Booting
EFI
GPT
EFI
2 GB
RAM
Video
4 GB
0 GB
HFS+
HFS+
/System/Library
CoreServices/boot.e
Caches/com.apple.kernelcaches/
Extensions
mach_kernel
http://clc.its.psu.edu/Labs/Mac/Resources/blastimagecong/images/SigBuild/Intel-Sig-BootPicker.JPG
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 ppc
libSystem.dylib (for architecture ppc64): Mach-O 64-bit dynamically linked shared library ppc64
libSystem.dylib (for architecture i386): Mach-O dynamically linked shared library i386
libSystem.dylib (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64
/usr/lib
/usr/lib64
C:\WINDOWS\SYSTEM
C:\WINDOWS\SYSTEM32
C:\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
$ le /mach_kernel
Rosetta
hardware
XNU
user
kernel
libSystem
libA libB libC
ppc
i386
hardware
XNU
libSystem
libB
PowerPC app
libC
Rosetta (byte swapping)
Rosetta (byte swapping)
PowerPC app
libA
Rosetta (dynarec)
R
o
s
e
t
t
a
(
d
y
n
a
r
e
c
)
Architectures
i386
i386
PA-RISC
SPARC
PowerPC
(i386) 68K
1990 1995 2000 2005
3/1 Split
kernel
user
Windows, Linux, ...
4 GB
3 GB
0 GB
user user user
user kernel user kernel
4/4 Split
Mac OS X Intel
4 GB
0 GB
switcher
user kernel user
4/4 Split
Mac OS X Intel
4 GB
0 GB
switcher
x86_64
kernel
intr handler
2^47
0
4 GB
user
kernel kernel
x86_64
kernel
intr handler
2^47
0
4 GB
user
x86_64
user
intr handler
2^47
0
4 GB
iPhone
ARM
Custom Bootloader
No real KEXTs
Kernel Cache
What Makes XNU Great
What Makes XNU Great
#8
dtrace
What Makes XNU Great
#7
kernel cache
What Makes XNU Great
#6
Separation between Mach, BSD, I/O-Kit
What Makes XNU Great
#5
POSIX Conformance
What Makes XNU Great
#4
Mach Message API
What Makes XNU Great
#3
I/O-Kit
What Makes XNU Great
#2
Stable KEXT ABI
What Makes XNU Great
#1
Universal Binaries
Buzzwords
again
Mach
Mac OS X is UNIX.
Thats a fact.
lucy