SlideShare uma empresa Scribd logo
1 de 33
Baixar para ler offline
第一次自幹作業系統核心
          就上手!



Jim Huang ( 黃敬群 ) <jserv@0xlab.org>
Developer, 0xlab / JuluOSDev - http://www.juluos.org/

                                      Aug 19, 2012 / COSCUP
作為 LXDE/PCManFM 的開發者,我
    也好想去聽隔壁的議程
          ~>_<~



                     2
「是個正常人,做正常人能做的事情」
        PCMan 自介 (2006)
    http://www.openfoundry.org/en/os-people/629




                                              3
設計與實做一套新的作業系統 ( 核
心 ) 絕對是正常人能作的事情,而且
對生活有益




                     4
Agenda   (1) 開發 OS Kernel 的動機
         (2) 以微核心來建構 OS Kernel
         (3) 立馬體驗




                                 5
開發 OS Kernel 的動機




                   6
動機
每年寫一套 ( 玩具 )
作業系統當作業
JK (2001; NCKU homework)
Orz Microkernel (2006)
RT nanokernel (2007; OSDC.tw)
Jamei RTOS (2007; COSCUP)
CuRT (2009; COSCUP)
TMK (2010; ICOS)
??? (2012; Assign homework to NCKU students)    7
Show Me the Robot!




                8
等等,開發作業系統核心有意義嗎?




               9
明明就有,
 明明就有,
但你沒看清楚
但你沒看清楚




         10
現在更需要開發作業系統核心的技能

• 許多 Web/Application Framework 師法先進
  作業系統的效能技巧
• 虛擬化技術
  – Hypervisor, Resource Kernel (KVM), ...
  – Intel VT-d / ARM Cortex-A15
• 資訊安全領域
  – 以特製的 VM 作動態分析與追蹤
• 逃離鬼島
 • NASA 需要你!


                                             11
以微核心建構 OS Kernel




                   12
策略: Nested Kernel

     • 直接將 OS Kernel 架構於一個成熟的 microkernel
       之上,避免直接碰觸硬體
     • 回歸「設計」本質
     • 將 microkernel 的 IPC/RPC 服務再進一步抽象




                                             13
L4Ka - http://www.l4ka.org/
MyOS
MyOS
                        L4 Sigma0

       L4 microkernel
       L4 microkernel




                                14
Microkernel 的三個世代

• Mach, Chorus (1985-1994)
  – 將 UNIX pipes 替換為 IPC ( 更通用 )
  – 改善系統穩定度 ( 與 monolithic 相比 )
  – 低劣的執行效能
• L3 & L4 (1990-2001)
  – 針對 IPC 大量的效能改善
  – 以組合語言開發,低可攜性
  – 只提供同步的 (sync) IPC
  – 非常小的實做,大部分的功能移到 userspace

• seL4, Coyotos, Nova (2000- 目前 )
  – 儘量作到與平台無關
  – verification, security, multiple CPUs, etc.
第二代 Microkernel (L4) 典型設計


Device Drivers     User Program       Memory
                                      Managers
                    User Mode


 Address spacing   Thread             Unique
                   Management         Identifiers
                   and IPC

                   Microkernel Mode


                      Hardware

                                                    16
遞迴式的 Address Space
Map
    ( 與其他 AS 分享 page)
        Memory Manager                      Memory Manager

                                                    Page Fault IPC

1
1      L4 microkernel                  2
                                       2   L4 microkernel




                          Page Grant
                              IPC
        Memory Manager   ( 將 page 給予        Memory Manager
                         其他 AS 存取 )



3
3     L4 microkernel                   4
                                       4   L4 microkernel
Map




• 若系統存在兩個不同 address space       Application
                                Application    Pager
                                               Pager
  的執行單元 ( 如 Process) ,而其中
  一者 (userA) 想要存取另一者
  (userB) 的記體體,只要將 userA
  設置為 userB 的 pager ( 記憶體管理
  單元 ) 並提供 userB 的 page fault
  handler 即可
• Sigma0 RPC 通訊協定是 L4 除了
  FastIPC 外,另一個主要的設計,
  用以處理記憶體管理
• 系統的 initial pager 為 sigma0 ,而
  MyOS 在 L4 的術語叫做 root task /
  server




                                  21
訊息傳遞機制 : Copy Data
•   直接與間接的資料複製
•   UTCB message (special area)
•   Special case: register-only message
•   Pagefaults during user-level memory access possible
Copy               TaskB Copy
            TaskA
                           Data Area
                                                    訊息傳遞
Data Area
                           UTCB
UTCB                       message          Msg
message
                    Msg
Capabilities   ( 執行特定 IPC 的權級單位 )
立馬體驗 :
自幹 MyOS



          26
27
在 OSDC.tw 2012 挑戰失敗,
在 OSDC.tw 2012 挑戰失敗,   28
群群轉戰 COSCUP 繼續自幹
群群轉戰 COSCUP 繼續自幹
MyOS
• 真的能動的 OS!
  – 建構於 L4Ka (Pistachio) 的基礎之上
• 以 CORBA 介面串連個別系統元件
 interface File {
     boolean Read(in Capability_t cap,
                  in unsigned long offset,
                  out byteseq_t buffer,
                  inout unsigned long size);
                  unsigned long Size(in Capability_t cap);
     ...
 }
• Name System
• 實做基本的檔案系統
• 提供 Tiny Ruby 一類的程式語言執行環境




                                                             29
「寫一個 OS 是多麼美好的事,在有
 限的生命中千萬不要遺漏了它」
    王佑中博士 (2009)



                 30
31
Reference

Microkernel Construction (SS2012), TU Dresden Operating
System Group

將 CuRT 用作大學作業系統教材 :
http://sites.google.com/site/embedded2009/introduction-to-curt-v1

Write Your Own Operating System [FAQ]:
http://www.superfrink.net/athenaeum/OS-FAQ/os-faq.html

SigOPS, How to Write an Operating System:
http://www.acm.uiuc.edu/sigops/roll_your_own/

OSDev Wiki: http://wiki.osdev.org/

                                                                    32
http://0xlab.org




                   33

Mais conteúdo relacionado

Mais procurados

給自己更好未來的 3 個練習:嵌入式作業系統設計、實做,與移植 (2015 年春季 ) 課程說明
給自己更好未來的 3 個練習:嵌入式作業系統設計、實做,與移植 (2015 年春季 ) 課程說明給自己更好未來的 3 個練習:嵌入式作業系統設計、實做,與移植 (2015 年春季 ) 課程說明
給自己更好未來的 3 個練習:嵌入式作業系統設計、實做,與移植 (2015 年春季 ) 課程說明National Cheng Kung University
 
ZynqMPのブートとパワーマネージメント : (ZynqMP Boot and Power Management)
ZynqMPのブートとパワーマネージメント : (ZynqMP Boot and Power Management)ZynqMPのブートとパワーマネージメント : (ZynqMP Boot and Power Management)
ZynqMPのブートとパワーマネージメント : (ZynqMP Boot and Power Management)Mr. Vengineer
 
Block I/O Layer Tracing: blktrace
Block I/O Layer Tracing: blktraceBlock I/O Layer Tracing: blktrace
Block I/O Layer Tracing: blktraceBabak Farrokhi
 
QEMU - Binary Translation
QEMU - Binary Translation QEMU - Binary Translation
QEMU - Binary Translation Jiann-Fuh Liaw
 
from Binary to Binary: How Qemu Works
from Binary to Binary: How Qemu Worksfrom Binary to Binary: How Qemu Works
from Binary to Binary: How Qemu WorksZhen Wei
 
Linux Kernel MMC Storage driver Overview
Linux Kernel MMC Storage driver OverviewLinux Kernel MMC Storage driver Overview
Linux Kernel MMC Storage driver OverviewRajKumar Rampelli
 
Linux kernel debugging
Linux kernel debuggingLinux kernel debugging
Linux kernel debuggingHao-Ran Liu
 
Valgrind tutorial
Valgrind tutorialValgrind tutorial
Valgrind tutorialSatabdi Das
 
HKG15-505: Power Management interactions with OP-TEE and Trusted Firmware
HKG15-505: Power Management interactions with OP-TEE and Trusted FirmwareHKG15-505: Power Management interactions with OP-TEE and Trusted Firmware
HKG15-505: Power Management interactions with OP-TEE and Trusted FirmwareLinaro
 
ARM Trusted FirmwareのBL31を単体で使う!
ARM Trusted FirmwareのBL31を単体で使う!ARM Trusted FirmwareのBL31を単体で使う!
ARM Trusted FirmwareのBL31を単体で使う!Mr. Vengineer
 
ARM LinuxのMMUはわかりにくい
ARM LinuxのMMUはわかりにくいARM LinuxのMMUはわかりにくい
ARM LinuxのMMUはわかりにくいwata2ki
 
Q2.12: Debugging with GDB
Q2.12: Debugging with GDBQ2.12: Debugging with GDB
Q2.12: Debugging with GDBLinaro
 
Linux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKBLinux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKBshimosawa
 
BPF: Tracing and more
BPF: Tracing and moreBPF: Tracing and more
BPF: Tracing and moreBrendan Gregg
 
規格書で読むC++11のスレッド
規格書で読むC++11のスレッド規格書で読むC++11のスレッド
規格書で読むC++11のスレッドKohsuke Yuasa
 

Mais procurados (20)

給自己更好未來的 3 個練習:嵌入式作業系統設計、實做,與移植 (2015 年春季 ) 課程說明
給自己更好未來的 3 個練習:嵌入式作業系統設計、實做,與移植 (2015 年春季 ) 課程說明給自己更好未來的 3 個練習:嵌入式作業系統設計、實做,與移植 (2015 年春季 ) 課程說明
給自己更好未來的 3 個練習:嵌入式作業系統設計、實做,與移植 (2015 年春季 ) 課程說明
 
ZynqMPのブートとパワーマネージメント : (ZynqMP Boot and Power Management)
ZynqMPのブートとパワーマネージメント : (ZynqMP Boot and Power Management)ZynqMPのブートとパワーマネージメント : (ZynqMP Boot and Power Management)
ZynqMPのブートとパワーマネージメント : (ZynqMP Boot and Power Management)
 
Block I/O Layer Tracing: blktrace
Block I/O Layer Tracing: blktraceBlock I/O Layer Tracing: blktrace
Block I/O Layer Tracing: blktrace
 
QEMU - Binary Translation
QEMU - Binary Translation QEMU - Binary Translation
QEMU - Binary Translation
 
from Binary to Binary: How Qemu Works
from Binary to Binary: How Qemu Worksfrom Binary to Binary: How Qemu Works
from Binary to Binary: How Qemu Works
 
Linux Kernel MMC Storage driver Overview
Linux Kernel MMC Storage driver OverviewLinux Kernel MMC Storage driver Overview
Linux Kernel MMC Storage driver Overview
 
Linux kernel debugging
Linux kernel debuggingLinux kernel debugging
Linux kernel debugging
 
Valgrind tutorial
Valgrind tutorialValgrind tutorial
Valgrind tutorial
 
HKG15-505: Power Management interactions with OP-TEE and Trusted Firmware
HKG15-505: Power Management interactions with OP-TEE and Trusted FirmwareHKG15-505: Power Management interactions with OP-TEE and Trusted Firmware
HKG15-505: Power Management interactions with OP-TEE and Trusted Firmware
 
ARM Trusted FirmwareのBL31を単体で使う!
ARM Trusted FirmwareのBL31を単体で使う!ARM Trusted FirmwareのBL31を単体で使う!
ARM Trusted FirmwareのBL31を単体で使う!
 
What Can Compilers Do for Us?
What Can Compilers Do for Us?What Can Compilers Do for Us?
What Can Compilers Do for Us?
 
ARM LinuxのMMUはわかりにくい
ARM LinuxのMMUはわかりにくいARM LinuxのMMUはわかりにくい
ARM LinuxのMMUはわかりにくい
 
Q2.12: Debugging with GDB
Q2.12: Debugging with GDBQ2.12: Debugging with GDB
Q2.12: Debugging with GDB
 
Linux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKBLinux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKB
 
BPF: Tracing and more
BPF: Tracing and moreBPF: Tracing and more
BPF: Tracing and more
 
Qemu JIT Code Generator and System Emulation
Qemu JIT Code Generator and System EmulationQemu JIT Code Generator and System Emulation
Qemu JIT Code Generator and System Emulation
 
規格書で読むC++11のスレッド
規格書で読むC++11のスレッド規格書で読むC++11のスレッド
規格書で読むC++11のスレッド
 
DDR3
DDR3DDR3
DDR3
 
Embedded Virtualization applied in Mobile Devices
Embedded Virtualization applied in Mobile DevicesEmbedded Virtualization applied in Mobile Devices
Embedded Virtualization applied in Mobile Devices
 
Understanding DPDK
Understanding DPDKUnderstanding DPDK
Understanding DPDK
 

Destaque

進階嵌入式系統開發與實作 (2013 秋季班 ) 課程說明
進階嵌入式系統開發與實作 (2013 秋季班 ) 課程說明進階嵌入式系統開發與實作 (2013 秋季班 ) 課程說明
進階嵌入式系統開發與實作 (2013 秋季班 ) 課程說明National Cheng Kung University
 
Shorten Device Boot Time for Automotive IVI and Navigation Systems
Shorten Device Boot Time for Automotive IVI and Navigation SystemsShorten Device Boot Time for Automotive IVI and Navigation Systems
Shorten Device Boot Time for Automotive IVI and Navigation SystemsNational Cheng Kung University
 
Lecture notice about Embedded Operating System Design and Implementation
Lecture notice about Embedded Operating System Design and ImplementationLecture notice about Embedded Operating System Design and Implementation
Lecture notice about Embedded Operating System Design and ImplementationNational Cheng Kung University
 
Develop Your Own Operating Systems using Cheap ARM Boards
Develop Your Own Operating Systems using Cheap ARM BoardsDevelop Your Own Operating Systems using Cheap ARM Boards
Develop Your Own Operating Systems using Cheap ARM BoardsNational Cheng Kung University
 
F9: A Secure and Efficient Microkernel Built for Deeply Embedded Systems
F9: A Secure and Efficient Microkernel Built for Deeply Embedded SystemsF9: A Secure and Efficient Microkernel Built for Deeply Embedded Systems
F9: A Secure and Efficient Microkernel Built for Deeply Embedded SystemsNational Cheng Kung University
 
進階嵌入式作業系統設計與實做 (2015 年秋季 ) 課程說明
進階嵌入式作業系統設計與實做 (2015 年秋季 ) 課程說明進階嵌入式作業系統設計與實做 (2015 年秋季 ) 課程說明
進階嵌入式作業系統設計與實做 (2015 年秋季 ) 課程說明National Cheng Kung University
 

Destaque (20)

Build Your Own Android Toolchain from scratch
Build Your Own Android Toolchain from scratchBuild Your Own Android Toolchain from scratch
Build Your Own Android Toolchain from scratch
 
進階嵌入式系統開發與實作 (2013 秋季班 ) 課程說明
進階嵌入式系統開發與實作 (2013 秋季班 ) 課程說明進階嵌入式系統開發與實作 (2013 秋季班 ) 課程說明
進階嵌入式系統開發與實作 (2013 秋季班 ) 課程說明
 
Faults inside System Software
Faults inside System SoftwareFaults inside System Software
Faults inside System Software
 
Open Source from Legend, Business, to Ecosystem
Open Source from Legend, Business, to EcosystemOpen Source from Legend, Business, to Ecosystem
Open Source from Legend, Business, to Ecosystem
 
Shorten Device Boot Time for Automotive IVI and Navigation Systems
Shorten Device Boot Time for Automotive IVI and Navigation SystemsShorten Device Boot Time for Automotive IVI and Navigation Systems
Shorten Device Boot Time for Automotive IVI and Navigation Systems
 
Lecture notice about Embedded Operating System Design and Implementation
Lecture notice about Embedded Operating System Design and ImplementationLecture notice about Embedded Operating System Design and Implementation
Lecture notice about Embedded Operating System Design and Implementation
 
Hints for L4 Microkernel
Hints for L4 MicrokernelHints for L4 Microkernel
Hints for L4 Microkernel
 
Implement Runtime Environments for HSA using LLVM
Implement Runtime Environments for HSA using LLVMImplement Runtime Environments for HSA using LLVM
Implement Runtime Environments for HSA using LLVM
 
olibc: Another C Library optimized for Embedded Linux
olibc: Another C Library optimized for Embedded Linuxolibc: Another C Library optimized for Embedded Linux
olibc: Another C Library optimized for Embedded Linux
 
Construct an Efficient and Secure Microkernel for IoT
Construct an Efficient and Secure Microkernel for IoTConstruct an Efficient and Secure Microkernel for IoT
Construct an Efficient and Secure Microkernel for IoT
 
Develop Your Own Operating Systems using Cheap ARM Boards
Develop Your Own Operating Systems using Cheap ARM BoardsDevelop Your Own Operating Systems using Cheap ARM Boards
Develop Your Own Operating Systems using Cheap ARM Boards
 
F9: A Secure and Efficient Microkernel Built for Deeply Embedded Systems
F9: A Secure and Efficient Microkernel Built for Deeply Embedded SystemsF9: A Secure and Efficient Microkernel Built for Deeply Embedded Systems
F9: A Secure and Efficient Microkernel Built for Deeply Embedded Systems
 
Explore Android Internals
Explore Android InternalsExplore Android Internals
Explore Android Internals
 
The Internals of "Hello World" Program
The Internals of "Hello World" ProgramThe Internals of "Hello World" Program
The Internals of "Hello World" Program
 
Microkernel Evolution
Microkernel EvolutionMicrokernel Evolution
Microkernel Evolution
 
Priority Inversion on Mars
Priority Inversion on MarsPriority Inversion on Mars
Priority Inversion on Mars
 
Hardware Accelerated 2D Rendering for Android
Hardware Accelerated 2D Rendering for AndroidHardware Accelerated 2D Rendering for Android
Hardware Accelerated 2D Rendering for Android
 
Xvisor: embedded and lightweight hypervisor
Xvisor: embedded and lightweight hypervisorXvisor: embedded and lightweight hypervisor
Xvisor: embedded and lightweight hypervisor
 
進階嵌入式作業系統設計與實做 (2015 年秋季 ) 課程說明
進階嵌入式作業系統設計與實做 (2015 年秋季 ) 課程說明進階嵌入式作業系統設計與實做 (2015 年秋季 ) 課程說明
進階嵌入式作業系統設計與實做 (2015 年秋季 ) 課程說明
 
Summer Project: Microkernel (2013)
Summer Project: Microkernel (2013)Summer Project: Microkernel (2013)
Summer Project: Microkernel (2013)
 

Semelhante a Develop Your Own Operating System

Erlang分布式系统的的领域语言
Erlang分布式系统的的领域语言Erlang分布式系统的的领域语言
Erlang分布式系统的的领域语言Feng Yu
 
開發人員必須知道的 Kubernetes 核心技術 - Kubernetes Summit 2018
開發人員必須知道的 Kubernetes 核心技術 - Kubernetes Summit 2018開發人員必須知道的 Kubernetes 核心技術 - Kubernetes Summit 2018
開發人員必須知道的 Kubernetes 核心技術 - Kubernetes Summit 2018Will Huang
 
豆瓣网技术架构变迁
豆瓣网技术架构变迁豆瓣网技术架构变迁
豆瓣网技术架构变迁reinhardx
 
Java线上应用问题排查方法和工具(空望)
Java线上应用问题排查方法和工具(空望)Java线上应用问题排查方法和工具(空望)
Java线上应用问题排查方法和工具(空望)ykdsg
 
Big Java, Big Data
Big Java, Big DataBig Java, Big Data
Big Java, Big DataKuo-Chun Su
 
Tilera和fos的学习
Tilera和fos的学习Tilera和fos的学习
Tilera和fos的学习sibeliuscn
 
基于MySQL开放复制协议的同步扩展
基于MySQL开放复制协议的同步扩展基于MySQL开放复制协议的同步扩展
基于MySQL开放复制协议的同步扩展Sky Jian
 
Lvs在大规模网络环境下的应用pukong
Lvs在大规模网络环境下的应用pukongLvs在大规模网络环境下的应用pukong
Lvs在大规模网络环境下的应用pukongMichael Zhang
 
MySQL新技术探索与实践
MySQL新技术探索与实践MySQL新技术探索与实践
MySQL新技术探索与实践Lixun Peng
 
MySQL新技术探索与实践
MySQL新技术探索与实践MySQL新技术探索与实践
MySQL新技术探索与实践Lixun Peng
 
0911 juluosdev a_journey_of_filesystem_on_jos
0911 juluosdev a_journey_of_filesystem_on_jos0911 juluosdev a_journey_of_filesystem_on_jos
0911 juluosdev a_journey_of_filesystem_on_josWaylin Ch
 
20030623 linuxbasic and-security
20030623 linuxbasic and-security20030623 linuxbasic and-security
20030623 linuxbasic and-security建融 黃
 
Baidu LSP and DISQL for Log Analysis
Baidu LSP and DISQL for Log AnalysisBaidu LSP and DISQL for Log Analysis
Baidu LSP and DISQL for Log AnalysisXiaoming Chen
 
CKAN 技術介紹 (基礎篇)
CKAN 技術介紹 (基礎篇)CKAN 技術介紹 (基礎篇)
CKAN 技術介紹 (基礎篇)Chengjen Lee
 
Linux Container Introduction
Linux Container IntroductionLinux Container Introduction
Linux Container Introduction家弘 周
 
Exadata training
Exadata trainingExadata training
Exadata trainingLouis liu
 
[嵌入式系統] 嵌入式系統進階
[嵌入式系統] 嵌入式系統進階[嵌入式系統] 嵌入式系統進階
[嵌入式系統] 嵌入式系統進階Simen Li
 

Semelhante a Develop Your Own Operating System (20)

Erlang分布式系统的的领域语言
Erlang分布式系统的的领域语言Erlang分布式系统的的领域语言
Erlang分布式系统的的领域语言
 
開發人員必須知道的 Kubernetes 核心技術 - Kubernetes Summit 2018
開發人員必須知道的 Kubernetes 核心技術 - Kubernetes Summit 2018開發人員必須知道的 Kubernetes 核心技術 - Kubernetes Summit 2018
開發人員必須知道的 Kubernetes 核心技術 - Kubernetes Summit 2018
 
豆瓣网技术架构变迁
豆瓣网技术架构变迁豆瓣网技术架构变迁
豆瓣网技术架构变迁
 
Java线上应用问题排查方法和工具(空望)
Java线上应用问题排查方法和工具(空望)Java线上应用问题排查方法和工具(空望)
Java线上应用问题排查方法和工具(空望)
 
Godson x86
Godson x86Godson x86
Godson x86
 
Big Java, Big Data
Big Java, Big DataBig Java, Big Data
Big Java, Big Data
 
Tilera和fos的学习
Tilera和fos的学习Tilera和fos的学习
Tilera和fos的学习
 
基于MySQL开放复制协议的同步扩展
基于MySQL开放复制协议的同步扩展基于MySQL开放复制协议的同步扩展
基于MySQL开放复制协议的同步扩展
 
Tcfsh bootcamp day2
 Tcfsh bootcamp day2 Tcfsh bootcamp day2
Tcfsh bootcamp day2
 
Some tips
Some tipsSome tips
Some tips
 
Lvs在大规模网络环境下的应用pukong
Lvs在大规模网络环境下的应用pukongLvs在大规模网络环境下的应用pukong
Lvs在大规模网络环境下的应用pukong
 
MySQL新技术探索与实践
MySQL新技术探索与实践MySQL新技术探索与实践
MySQL新技术探索与实践
 
MySQL新技术探索与实践
MySQL新技术探索与实践MySQL新技术探索与实践
MySQL新技术探索与实践
 
0911 juluosdev a_journey_of_filesystem_on_jos
0911 juluosdev a_journey_of_filesystem_on_jos0911 juluosdev a_journey_of_filesystem_on_jos
0911 juluosdev a_journey_of_filesystem_on_jos
 
20030623 linuxbasic and-security
20030623 linuxbasic and-security20030623 linuxbasic and-security
20030623 linuxbasic and-security
 
Baidu LSP and DISQL for Log Analysis
Baidu LSP and DISQL for Log AnalysisBaidu LSP and DISQL for Log Analysis
Baidu LSP and DISQL for Log Analysis
 
CKAN 技術介紹 (基礎篇)
CKAN 技術介紹 (基礎篇)CKAN 技術介紹 (基礎篇)
CKAN 技術介紹 (基礎篇)
 
Linux Container Introduction
Linux Container IntroductionLinux Container Introduction
Linux Container Introduction
 
Exadata training
Exadata trainingExadata training
Exadata training
 
[嵌入式系統] 嵌入式系統進階
[嵌入式系統] 嵌入式系統進階[嵌入式系統] 嵌入式系統進階
[嵌入式系統] 嵌入式系統進階
 

Mais de National Cheng Kung University

Mais de National Cheng Kung University (8)

PyPy's approach to construct domain-specific language runtime
PyPy's approach to construct domain-specific language runtimePyPy's approach to construct domain-specific language runtime
PyPy's approach to construct domain-specific language runtime
 
Making Linux do Hard Real-time
Making Linux do Hard Real-timeMaking Linux do Hard Real-time
Making Linux do Hard Real-time
 
2016 年春季嵌入式作業系統課程說明
2016 年春季嵌入式作業系統課程說明2016 年春季嵌入式作業系統課程說明
2016 年春季嵌入式作業系統課程說明
 
Interpreter, Compiler, JIT from scratch
Interpreter, Compiler, JIT from scratchInterpreter, Compiler, JIT from scratch
Interpreter, Compiler, JIT from scratch
 
Virtual Machine Constructions for Dummies
Virtual Machine Constructions for DummiesVirtual Machine Constructions for Dummies
Virtual Machine Constructions for Dummies
 
從線上售票看作業系統設計議題
從線上售票看作業系統設計議題從線上售票看作業系統設計議題
從線上售票看作業系統設計議題
 
進階嵌入式系統開發與實做 (2014 年秋季 ) 課程說明
進階嵌入式系統開發與實做 (2014 年秋季 ) 課程說明進階嵌入式系統開發與實做 (2014 年秋季 ) 課程說明
進階嵌入式系統開發與實做 (2014 年秋季 ) 課程說明
 
Making Linux do Hard Real-time
Making Linux do Hard Real-timeMaking Linux do Hard Real-time
Making Linux do Hard Real-time
 

Develop Your Own Operating System

  • 1. 第一次自幹作業系統核心 就上手! Jim Huang ( 黃敬群 ) <jserv@0xlab.org> Developer, 0xlab / JuluOSDev - http://www.juluos.org/ Aug 19, 2012 / COSCUP
  • 2. 作為 LXDE/PCManFM 的開發者,我 也好想去聽隔壁的議程 ~>_<~ 2
  • 3. 「是個正常人,做正常人能做的事情」 PCMan 自介 (2006) http://www.openfoundry.org/en/os-people/629 3
  • 4. 設計與實做一套新的作業系統 ( 核 心 ) 絕對是正常人能作的事情,而且 對生活有益 4
  • 5. Agenda (1) 開發 OS Kernel 的動機 (2) 以微核心來建構 OS Kernel (3) 立馬體驗 5
  • 6. 開發 OS Kernel 的動機 6
  • 7. 動機 每年寫一套 ( 玩具 ) 作業系統當作業 JK (2001; NCKU homework) Orz Microkernel (2006) RT nanokernel (2007; OSDC.tw) Jamei RTOS (2007; COSCUP) CuRT (2009; COSCUP) TMK (2010; ICOS) ??? (2012; Assign homework to NCKU students) 7
  • 8. Show Me the Robot! 8
  • 11. 現在更需要開發作業系統核心的技能 • 許多 Web/Application Framework 師法先進 作業系統的效能技巧 • 虛擬化技術 – Hypervisor, Resource Kernel (KVM), ... – Intel VT-d / ARM Cortex-A15 • 資訊安全領域 – 以特製的 VM 作動態分析與追蹤 • 逃離鬼島 • NASA 需要你! 11
  • 13. 策略: Nested Kernel • 直接將 OS Kernel 架構於一個成熟的 microkernel 之上,避免直接碰觸硬體 • 回歸「設計」本質 • 將 microkernel 的 IPC/RPC 服務再進一步抽象 13 L4Ka - http://www.l4ka.org/
  • 14. MyOS MyOS L4 Sigma0 L4 microkernel L4 microkernel 14
  • 15. Microkernel 的三個世代 • Mach, Chorus (1985-1994) – 將 UNIX pipes 替換為 IPC ( 更通用 ) – 改善系統穩定度 ( 與 monolithic 相比 ) – 低劣的執行效能 • L3 & L4 (1990-2001) – 針對 IPC 大量的效能改善 – 以組合語言開發,低可攜性 – 只提供同步的 (sync) IPC – 非常小的實做,大部分的功能移到 userspace • seL4, Coyotos, Nova (2000- 目前 ) – 儘量作到與平台無關 – verification, security, multiple CPUs, etc.
  • 16. 第二代 Microkernel (L4) 典型設計 Device Drivers User Program Memory Managers User Mode Address spacing Thread Unique Management Identifiers and IPC Microkernel Mode Hardware 16
  • 17.
  • 19. Map ( 與其他 AS 分享 page) Memory Manager Memory Manager Page Fault IPC 1 1 L4 microkernel 2 2 L4 microkernel Page Grant IPC Memory Manager ( 將 page 給予 Memory Manager 其他 AS 存取 ) 3 3 L4 microkernel 4 4 L4 microkernel
  • 20. Map • 若系統存在兩個不同 address space Application Application Pager Pager 的執行單元 ( 如 Process) ,而其中 一者 (userA) 想要存取另一者 (userB) 的記體體,只要將 userA 設置為 userB 的 pager ( 記憶體管理 單元 ) 並提供 userB 的 page fault handler 即可
  • 21. • Sigma0 RPC 通訊協定是 L4 除了 FastIPC 外,另一個主要的設計, 用以處理記憶體管理 • 系統的 initial pager 為 sigma0 ,而 MyOS 在 L4 的術語叫做 root task / server 21
  • 22. 訊息傳遞機制 : Copy Data • 直接與間接的資料複製 • UTCB message (special area) • Special case: register-only message • Pagefaults during user-level memory access possible
  • 23. Copy TaskB Copy TaskA Data Area 訊息傳遞 Data Area UTCB UTCB message Msg message Msg
  • 24.
  • 25. Capabilities ( 執行特定 IPC 的權級單位 )
  • 27. 27
  • 28. 在 OSDC.tw 2012 挑戰失敗, 在 OSDC.tw 2012 挑戰失敗, 28 群群轉戰 COSCUP 繼續自幹 群群轉戰 COSCUP 繼續自幹
  • 29. MyOS • 真的能動的 OS! – 建構於 L4Ka (Pistachio) 的基礎之上 • 以 CORBA 介面串連個別系統元件 interface File { boolean Read(in Capability_t cap, in unsigned long offset, out byteseq_t buffer, inout unsigned long size); unsigned long Size(in Capability_t cap); ... } • Name System • 實做基本的檔案系統 • 提供 Tiny Ruby 一類的程式語言執行環境 29
  • 30. 「寫一個 OS 是多麼美好的事,在有 限的生命中千萬不要遺漏了它」 王佑中博士 (2009) 30
  • 31. 31
  • 32. Reference Microkernel Construction (SS2012), TU Dresden Operating System Group 將 CuRT 用作大學作業系統教材 : http://sites.google.com/site/embedded2009/introduction-to-curt-v1 Write Your Own Operating System [FAQ]: http://www.superfrink.net/athenaeum/OS-FAQ/os-faq.html SigOPS, How to Write an Operating System: http://www.acm.uiuc.edu/sigops/roll_your_own/ OSDev Wiki: http://wiki.osdev.org/ 32