陳膺正 (Hawx Chen )
yingjheng.chen@gmail.com
http://hawxchen.blogspot.tw
Exokernel
vs.
Microkernel
Who Am I
• Experience
– 2008 NCTU CS Bachelor
– 2010 NTU CSIE Master
– 2010~presnet MStar Semiconductor
• Senior software engineer
• Talk:
– 2012 COSCUP.
– 2013 COSCUP.
• Open Source
– https://github.com/HawxChen/MIT-6.828-Adventure
Enjoy to implement OS.
Outline
• Importance of History
• Base Arch
• Exokernel Principle
• Example: page handling
• Geek Part
Outline
• Importance of History
• Base Arch
• Exokernel Principle
• Example: page handling
• Geek Part
Importance of History
Unics UNIXv6
MINIXMTS
LinuxBSD
L4
1975
Exokernel
199519871967
1969 1978 1991
Time
Importance of history
A.D 1967
Hardware
Importance of history
Hardware
Exokernel
LibOS
App
LibOS’
App’
LibOS’’
App’’
Pager Swapper Ignore
pag e fault
A.D 1995
User mode
Kernel mode
Outline
• Importance of History
• Base Arch
• Exokernel Principle
• Example: page handling
• Geek Part
UNIX Arch
User Process
System Call
Interface (Library Routines)
User Process
Hardware
Process
Management
Memory
Management File
System
I/O Services
Scheduler
I/O Buffers
Device
Drivers
Kernel Space
MINIX Arch
Kernel Space
Scheduler/ message passing Memory copy
Exokernel Arch: Aegis/ExOS
Kernel Space
Libs’Libs
ExOS has
TCP, IPC, and FS.
App App’
ExOS’ has
VM, POSIX, and
Scheduler.
Libs’’
ExOS’’ has
Timer Service
Routine.
App’’
Disk TLB Network Memory Frame buffer
Resource
Allocation
Resource
Revocation
Information
Query Protection
Outline
• Importance of History
• Base Arch
• Exokernel Principle and Design
• Example: page handling
• Geek Part
Exokernel Principle
1. Separate protection from management
2. Expose Names
3. Expose allocation
4. Expose Revocation
5. Expose Information
Library Operating System
(Replaceable )
Exokernel Approach
VMIPC
Traps
Vecs
Distributed Shared
MemoryWWW
POSIX TCP
Disk TLB Network Memory Frame buffer
Mosaic Barnes-HutApps
Library
Kernel
HW
Expose allocation/revocation/names/information,
and Support Protection
Exokernel Approach
VMIPC
Traps
Vecs
Distributed Shared
Memory
WWW
POSIX TCP
Expose allocation/revocation/names/information,
and Support Protection
Disk TLB Network Memory Frame buffer
Mosaic Barnes-Hut
CPL = 3
CPL = 0
Library Operating System
(Replaceable )
Apps
Library
Kernel
HW
Design: Monolithic kernel
Hardware
Scheduler
Timer Services
IPC, Signal, System Calls,
POSIX
File Systems: ext2, ext3, NFS,… etc. VFS
Memory manager.
…
…
Device drivers
Proc1 Proc2 Proc3 Proc4 Proc5 Proc6 Proc7
Kernel Space
Design: Microkernel
Hardware
Kernel Space
Design: Exokernel
WWW
POSIX TCP
Expose allocation/revocation/names/information,
and Support Protection
Mosaic
VMIPC
Traps
Distributed Shared
Memory
Barnes-Hut
Kernel Space
Hardware
Outline
• Importance of History
• Base Arch
• Exokernel Principle
• Example: page handling
• Geek Part
Exokernel Way
Page fault
Exception
Page Fault Handler
LibOS
App
Pager
LibOS
App
Pager: Now
You See Me.(
Exception
Vector Table
Hardware
Exokernel
………….
………….
………….
………….
………….
1. Trigger the page fault
exception
2. Query exception vector
table
3. Page fault handler (trick)
4. Translate to real pager
5. Allocate a free page
6. Map
7. UnMap
8. Adjust the stack (trick)
9. Return to the fault
happening instruction
CPL = 3
CPL = 0
Outline
• Importance of History
• Base Arch
• Exokernel Principle
• Example: page handling
• Geek Part
Geek Part
• Make page fault handler execute in user mode.
– Expose something out of kernel
– The stack trick
• Implementation:
– https://github.com/HawxChen/MIT-6.828-
Adventure/tree/lab4
Stack
Page Fault Happening.
WWW
POSIX
TCP
Expose allocation/revocation/names/information,
and Support Protection
Disk TLB Network Memory Frame buffer
Mosaic
Apps
Library Operating System
(Replaceable )
Exokernel
HW
CPL=3
CPL=0User Context
Pager
0xEEEEEEEE: esp
0xBBBBBBBB:esp
0x00001688:eip
&(pager):eip
EIP: 0x00001688
-> &(pager):eip
ESP: 0xEEEEEEEE
-> 0xBBBBBBBB Page fault
handler
Page fault handler (trick)
Adjust the stack (trick)
0x00001688:eip
ret
Conclusion
• App and OS co-design.
• Application driven design.
• Don’t limit app’s scalability.
– Everyone is ambitious.
Reference
Thanks

[TALK] Exokernel vs. Microkernel

  • 1.
    陳膺正 (Hawx Chen) yingjheng.chen@gmail.com http://hawxchen.blogspot.tw Exokernel vs. Microkernel
  • 2.
    Who Am I •Experience – 2008 NCTU CS Bachelor – 2010 NTU CSIE Master – 2010~presnet MStar Semiconductor • Senior software engineer • Talk: – 2012 COSCUP. – 2013 COSCUP. • Open Source – https://github.com/HawxChen/MIT-6.828-Adventure Enjoy to implement OS.
  • 3.
    Outline • Importance ofHistory • Base Arch • Exokernel Principle • Example: page handling • Geek Part
  • 4.
    Outline • Importance ofHistory • Base Arch • Exokernel Principle • Example: page handling • Geek Part
  • 5.
    Importance of History UnicsUNIXv6 MINIXMTS LinuxBSD L4 1975 Exokernel 199519871967 1969 1978 1991 Time
  • 6.
  • 7.
  • 8.
    Outline • Importance ofHistory • Base Arch • Exokernel Principle • Example: page handling • Geek Part
  • 9.
    UNIX Arch User Process SystemCall Interface (Library Routines) User Process Hardware Process Management Memory Management File System I/O Services Scheduler I/O Buffers Device Drivers Kernel Space
  • 10.
    MINIX Arch Kernel Space Scheduler/message passing Memory copy
  • 11.
    Exokernel Arch: Aegis/ExOS KernelSpace Libs’Libs ExOS has TCP, IPC, and FS. App App’ ExOS’ has VM, POSIX, and Scheduler. Libs’’ ExOS’’ has Timer Service Routine. App’’ Disk TLB Network Memory Frame buffer Resource Allocation Resource Revocation Information Query Protection
  • 12.
    Outline • Importance ofHistory • Base Arch • Exokernel Principle and Design • Example: page handling • Geek Part
  • 13.
    Exokernel Principle 1. Separateprotection from management 2. Expose Names 3. Expose allocation 4. Expose Revocation 5. Expose Information
  • 14.
    Library Operating System (Replaceable) Exokernel Approach VMIPC Traps Vecs Distributed Shared MemoryWWW POSIX TCP Disk TLB Network Memory Frame buffer Mosaic Barnes-HutApps Library Kernel HW Expose allocation/revocation/names/information, and Support Protection
  • 15.
    Exokernel Approach VMIPC Traps Vecs Distributed Shared Memory WWW POSIXTCP Expose allocation/revocation/names/information, and Support Protection Disk TLB Network Memory Frame buffer Mosaic Barnes-Hut CPL = 3 CPL = 0 Library Operating System (Replaceable ) Apps Library Kernel HW
  • 16.
    Design: Monolithic kernel Hardware Scheduler TimerServices IPC, Signal, System Calls, POSIX File Systems: ext2, ext3, NFS,… etc. VFS Memory manager. … … Device drivers Proc1 Proc2 Proc3 Proc4 Proc5 Proc6 Proc7 Kernel Space
  • 17.
  • 18.
    Design: Exokernel WWW POSIX TCP Exposeallocation/revocation/names/information, and Support Protection Mosaic VMIPC Traps Distributed Shared Memory Barnes-Hut Kernel Space Hardware
  • 19.
    Outline • Importance ofHistory • Base Arch • Exokernel Principle • Example: page handling • Geek Part
  • 20.
    Exokernel Way Page fault Exception PageFault Handler LibOS App Pager LibOS App Pager: Now You See Me.( Exception Vector Table Hardware Exokernel …………. …………. …………. …………. …………. 1. Trigger the page fault exception 2. Query exception vector table 3. Page fault handler (trick) 4. Translate to real pager 5. Allocate a free page 6. Map 7. UnMap 8. Adjust the stack (trick) 9. Return to the fault happening instruction CPL = 3 CPL = 0
  • 21.
    Outline • Importance ofHistory • Base Arch • Exokernel Principle • Example: page handling • Geek Part
  • 22.
    Geek Part • Makepage fault handler execute in user mode. – Expose something out of kernel – The stack trick • Implementation: – https://github.com/HawxChen/MIT-6.828- Adventure/tree/lab4
  • 23.
    Stack Page Fault Happening. WWW POSIX TCP Exposeallocation/revocation/names/information, and Support Protection Disk TLB Network Memory Frame buffer Mosaic Apps Library Operating System (Replaceable ) Exokernel HW CPL=3 CPL=0User Context Pager 0xEEEEEEEE: esp 0xBBBBBBBB:esp 0x00001688:eip &(pager):eip EIP: 0x00001688 -> &(pager):eip ESP: 0xEEEEEEEE -> 0xBBBBBBBB Page fault handler Page fault handler (trick) Adjust the stack (trick) 0x00001688:eip ret
  • 24.
    Conclusion • App andOS co-design. • Application driven design. • Don’t limit app’s scalability. – Everyone is ambitious.
  • 25.
  • 26.