Microkernels and L4: COMP9242 2006/S2 Week 1
Microkernels and L4: COMP9242 2006/S2 Week 1
Introduction
cse/UNSW/NICTA
W HY M ICROKERNELS ?
M ONOLITHIC KERNEL
W HY M ICROKERNELS ?
M ONOLITHIC KERNEL :
M ONOLITHIC KERNEL :
M ONOLITHIC KERNEL :
• Cost: Complexity
Ü growing size
Ü limited maintainability
Application
syscall
user
mode
VFS
Hardware Hardware
Application
Service
Hardware
System: traditional
embedded
T RUSTED C OMPUTING BASE
Application
Service
Hardware
System: traditional
embedded
T RUSTED C OMPUTING BASE
Application
Service
Hardware
System: traditional
embedded
T RUSTED C OMPUTING BASE
Application
Application
OS
Service Service
Hardware Hardware
Application
Application
OS
Service Service
Hardware Hardware
Application
Application
OS
Service Service
Hardware Hardware
Application
Application
OS
Service Service
Hardware Hardware
Application
Application
OS
Service Service
Hardware Hardware
Application Application
Application
OS
Service
Service Service
Microkernel
Hardware Hardware Hardware
Application Application
Application
OS
Service
Service Service
Microkernel
Hardware Hardware Hardware
Application Application
Application
OS
Service
Service Service
Microkernel
Hardware Hardware Hardware
Application Application
Application
OS
Service
Service Service
Microkernel
Hardware Hardware Hardware
Application Application
Application
OS
Service
Service Service
Microkernel
Hardware Hardware Hardware
Application Application
Application
OS
Service
Service Service
Microkernel
Hardware Hardware Hardware
• Hardware abstraction
Ü hardware-dependent part of system is small, easy to optimise
• Security, safety
Ü internal protection boundaries
M ICROKERNEL P ROMISES
!
• Combat kernel complexity, increase robustness, maintainability
K
Ü dramatic reduction of amount of privilegedC
Ü modularisation with hardware-enforcedE
code
C
Ü normal resource management applicable
H interfaces
to system services
I T Y
A L
• Flexibility, adaptability, extensibility
Ü additionalR
E
Ü policies defined at user level, easy to change
services provided by adding servers
• Hardware abstraction
Ü hardware-dependent part of system is small, easy to optimise
• Security, safety
Ü internal protection boundaries
M ICROKERNEL P ROMISES
!
• Combat kernel complexity, increase robustness, maintainability
K
Ü dramatic reduction of amount of privilegedC
Ü modularisation with hardware-enforcedE
code
C H interfaces
e
Ü normal resource management applicable
Y i b l
to system services
L I
• Flexibility, adaptability, T extensibility x
e
E
Ü policies defined Aat user level,
i
easyn fl
to change
Ü additionalR
w
services provided by, adding servers
• Hardware abstraction s l o
Ü hardware-dependent part of system is small, easy to optimise
• Security, safety
Ü internal protection boundaries
M ICROKERNEL P ROMISES
!
• Combat kernel complexity, increase robustness, maintainability
K
Ü dramatic reduction of amount of privilegedC
Ü modularisation with hardware-enforcedE
code
C H interfaces
e
Ü normal resource management applicable
Y i b l
to system services
L I
• Flexibility, adaptability, T extensibility x
e
E A n fl
to change IP
C
Ü policies defined
Ü additionalR , i
at user level, easy
c
l o w
services provided by
e
adding servers
s
• Hardware abstraction s 00µ
Ü hardware-dependent part1 of system is small, easy to optimise
• Security, safety
Ü internal protection boundaries
• First-generation microkernels
Ü Mach, Chorus, Amoeba
IPC C OSTS
• First-generation microkernels
Ü Mach, Chorus, Amoeba
• First-generation microkernels
Ü Mach, Chorus, Amoeba
• L4 does better
Ü close to hardware cost
Ü 20 times faster than Mach
on identical hardware
• Other L4 V2 implementations:
Ü L4/MIPS64: assembler + C (UNSW) 95–97
Ü fastest kernel on single-issue CPU (100 cycles)
Ü L4/Alpha: PAL + C (Dresden/UNSW), 95–97
Ü first released SMP version
Ü Fiasco (Pentium): C++ (Dresden), 97–99
• Implementations
Ü Pentium: assembler, Liedtke (IBM), 97-98
Ü Hazelnut (Pentium+ARM), C, Liedtke et al (Karlsruhe), 98–99
• Portable kernel:
Ü ≈ 3 person months for core functionality
Ü 6–12 person months for full functionality & optimisation
• Features:
Ü user-level management of kernel resources (esp. memory)
Ü low-overhead information-flow control mechanisms
Ü suitable for formal verification
L4 F UTURE
• Features:
Ü user-level management of kernel resources (esp. memory)
Ü low-overhead information-flow control mechanisms
Ü suitable for formal verification
• Source code:
Ü ≈ 10k loc architecture independent
Ü ≈ 0.5–2k loc architecture specific
P ISTACHIO : S IZE
• Source code:
Ü ≈ 10k loc architecture independent
Ü ≈ 0.5–2k loc architecture specific
• Source code:
Ü ≈ 10k loc architecture independent
Ü ≈ 0.5–2k loc architecture specific
†
“Version 2” assembler kernel
‡
Guestimate!
• Address spaces
• Threads
T WO BASIC MECHANISMS :
• Mapping
• Root task
Ü initial address space created at boot time
Ü controls system resources
Ü non-delegatable privilege (shortcoming of N2 API)
• Thread attributes:
Ü scheduling parameters (time slice, priority)
Ü unique ID
Ü address space
Ü page-fault and exception handler
Physical Memory
Root Task
Physical Memory
Driver Driver
Root Task
Physical Memory
Root Task
Physical Memory
Root Task
Physical Memory
• Interrupts
• Page faults
• Other exceptions
L4 E XCEPTION H ANDLING
• Interrupts
Ü modelled as hardware “thread” sending messages
Ü received by registered (user-level) interrupt-handler thread
Ü interrupt acknowledged when handler blocks on receive
Ü timer interrupt handled in-kernel
• Page faults
• Other exceptions
L4 E XCEPTION H ANDLING
• Interrupts
Ü modelled as hardware “thread” sending messages
Ü received by registered (user-level) interrupt-handler thread
Ü interrupt acknowledged when handler blocks on receive
Ü timer interrupt handled in-kernel
• Page faults
Ü kernel fakes IPC message from faulting thread to its pager
Ü pager requests root task to set up a mapping
Ü pager replies to faulting client, message intercepted by kernel
• Other exceptions
L4 E XCEPTION H ANDLING
• Interrupts
Ü modelled as hardware “thread” sending messages
Ü received by registered (user-level) interrupt-handler thread
Ü interrupt acknowledged when handler blocks on receive
Ü timer interrupt handled in-kernel
• Page faults
Ü kernel fakes IPC message from faulting thread to its pager
Ü pager requests root task to set up a mapping
Ü pager replies to faulting client, message intercepted by kernel
• Other exceptions
Ü kernel fakes IPC message from exceptor thread to its exception handler
Ü exception handler may reply with message specifying new IP, SP
Ü can be signal handler, emulation code, stub for IPCing to server, ...
• VM management
Ü performed by (hierarchy) of user-level pagers
F EATURES N OT I N K ERNEL
• VM management
Ü performed by (hierarchy) of user-level pagers
• Device drivers
Ü user-level threads registered for interrupt IPC
Ü map device registers