L4/Darwin: Evolving UNIX Charles Gray Research Engineer, National - - PowerPoint PPT Presentation

l4 darwin evolving unix
SMART_READER_LITE
LIVE PREVIEW

L4/Darwin: Evolving UNIX Charles Gray Research Engineer, National - - PowerPoint PPT Presentation

L4/Darwin: Evolving UNIX Charles Gray Research Engineer, National ICT Australia charles.gray@nicta.com.au Outline 1. Project Overview 2. BSD on the Mach microkernel 3. Porting Darwin to the L4 microkernel 4. Project Status 2 Darbat


slide-1
SLIDE 1

L4/Darwin: Evolving UNIX

Charles Gray Research Engineer, National ICT Australia charles.gray@nicta.com.au

slide-2
SLIDE 2

Outline

  • 1. Project Overview
  • 2. BSD on the Mach microkernel
  • 3. Porting Darwin to the L4 microkernel
  • 4. Project Status

2

slide-3
SLIDE 3

Darbat Overview

  • Para-virtualised Darwin kernel
  • L4 μ-kernel hypervisor
  • Isolated kernel and device drivers
  • Standard virtualisation benefits

3

slide-4
SLIDE 4

Why?

  • Virtualisation
  • Flexibility
  • Robustness
  • Code size

4

slide-5
SLIDE 5

Linux Kernel Size (LoC)

5

1,000,000 2,000,000 3,000,000 4,000,000 5,000,000 6,000,000 7,000,000 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006

slide-6
SLIDE 6

Mach

  • Once a hot research

topic

  • Many attempts at BSD
  • n Mach
  • Darwin is a monolithic

Mach kernel

  • Gave microkernels a

bad name

6

Hardware Mach

Kernel User

Process Mgr Network Application Application File System Disk

slide-7
SLIDE 7

What’s in a kernel?

  • XML parser
  • Decompression algorithms
  • Linker
  • Network routing

7

  • Device drivers
  • Strings
slide-8
SLIDE 8

Mac OS X Architecture

8

Hardware

Kernel User

launchd Aqua GUI xnu UNIX App OS X App

Darwin

slide-9
SLIDE 9

Darwin

  • Unique kernel design
  • Mach 3.0 μ-kernel
  • 4.4 BSD derivative
  • I/O Kit device drivers
  • Mac OS X applications
  • Full FreeBSD 5 UNIX

environment

9

Hardware Mach

Kernel User

UNIX App OS X App I/O Kit BSD

slide-10
SLIDE 10

BSD Layer

10

Kernel User

Mach I/O Kit BSD

Threads Process

VM UBC

fork() mmap() listen()

UFS HFS+ TCP

interrupt

Scheduler PCI Bus Disk Network

slide-11
SLIDE 11

The I/O Kit

11

Kernel User

Mach I/O Kit BSD

mach_msg() interrupt

PCI Bus ATA NIC

paging

Disk0 Disk1 Partition0 Partition1 UHCI Keyboard User Client HFS+

slide-12
SLIDE 12

BSD and I/O Kit

12

Kernel User

I/O Kit BSD

ioctl()

ATA Disk0 Disk1 Partition0 Partition1 HFS+

bdevsw

SCSI

read()

slide-13
SLIDE 13

L4

  • 2nd generation u-kernel
  • Learn from mistakes of Mach
  • Pay attention to cache, TLB, complexity
  • Make microkernels work
  • 10-20x performance improvement over Mach

13

slide-14
SLIDE 14

L4 μ-kernel

14

Hardware L4

Kernel User

OS Kernel Application Application Application

★not to scale

interrupt page-fault / exception

Threads Address Spaces IPC Scheduler

slide-15
SLIDE 15

Darbat

  • Decompose Darwin kernel
  • Tackle complexity problem
  • Add flexibility
  • Maintain (or improve) performance
  • All with binary compatibility

15

slide-16
SLIDE 16

Mach

  • Drv. Stub

BSD xnuglue I/O Kit BSD stub

Darbat Model

16

UNIX App OS X App Hardware L4

Kernel User

Mach

  • Drv. Stub

BSD xnuglue I/O Kit BSD stub

timer interrupt

slide-17
SLIDE 17

XNU on L4

17

Mach

ISR Thread Work-loop Thread

timer exception

  • int. mask

page faults syscalls

I/O Kit

slide-18
SLIDE 18

Server Consolidation

18

  • Multiple OS instances
  • Kernel support
  • Simplified driver model

Hardware L4

Kernel User

I/O Kit xnu xnu

slide-19
SLIDE 19

Crashable Drivers

19

Hardware L4

Kernel User

  • Drivers crash
  • Holding locks
  • Hogging resources
  • Can isolate drivers
  • and keep performance
  • Some devices still

critical

Disk Stack Network Stack xnu

slide-20
SLIDE 20

VM Aware Scheduling

20

Hardware L4

Kernel User

xnu xnu xnu Application Application Application Application Application

priority

slide-21
SLIDE 21

Reliable Servers

  • Microkernel is very

resilient

  • Protect data from 3rd

party modules

  • Ensure reliable

execution of code

  • Cheaper software

solutions

21

Hardware L4

Kernel User

I/O Kit xnu Watchdog Key Mgr.

slide-22
SLIDE 22

Heterogeneous Systems

  • L4 is OS (everything?)

agnostic

  • Linux
  • *BSD
  • Share devices
  • Share file systems

22

Hardware L4

Kernel User

I/O Kit xnu Wombat Linux

slide-23
SLIDE 23

23

System Call Performance

Hardware L4

Kernel User

xnu UNIX App

mach_msg null operation ~2400 cycles

Hardware

Kernel User

xnu UNIX App

~2500 cycles Mac OS X 10.4.7 Darbat 0.2

slide-24
SLIDE 24

In-task Synchronisation

24

Hardware L4

Kernel User

pthreads synchronisation ~6,500 cycles

Hardware

Kernel User

xnu UNIX App

~17,000 cycles Mac OS X 10.4.7 Darbat

UNIX App

slide-25
SLIDE 25

IPC Optimisation

  • L4 IPC is a subset of

Mach IPC

  • Applications rely on

Mach semantics

  • Optimisation for some

messages

25

Hardware L4

Kernel User

xnu OS X App OS X App

slide-26
SLIDE 26

Kernel Scripting

26

Hardware L4

Kernel User

I/O Kit xnu Python

  • Sometimes you just

need a hack

  • In-kernel scripts get

messy

  • Scheduling and locks

are a pain

  • Don’t compromise the

whole system

slide-27
SLIDE 27

Lessons So Far

  • Darwin modularity
  • Binary compatibility
  • Mac OS X has bugs
  • Performance
  • Debugging

27

slide-28
SLIDE 28

Future Work?

  • Further decomposition
  • Improved xnu and I/O Kit bindings
  • Usable system!
  • Experiment with features
  • System benchmarks

28

slide-29
SLIDE 29

Summary

  • UNIX kernels are feature-packed
  • L4 is one option to address this problem
  • Extend UNIX kernel to meet modern usage

Questions?

29