Running on the Bare Metal with GeekOS David Hovemeyer, Jeffrey K. - - PowerPoint PPT Presentation

running on the bare metal with geekos
SMART_READER_LITE
LIVE PREVIEW

Running on the Bare Metal with GeekOS David Hovemeyer, Jeffrey K. - - PowerPoint PPT Presentation

Running on the Bare Metal with GeekOS David Hovemeyer, Jeffrey K. Hollingsworth, and Bobby Bhattacharjee University of Maryland, College Park 1 Outline Motivation Overview Projects Classroom Experience Conclusions 2 OS


slide-1
SLIDE 1

1

Running on the Bare Metal with GeekOS

David Hovemeyer, Jeffrey K. Hollingsworth, and Bobby Bhattacharjee University of Maryland, College Park

slide-2
SLIDE 2

2

Outline

  • Motivation
  • Overview
  • Projects
  • Classroom Experience
  • Conclusions
slide-3
SLIDE 3

3

OS Kernel == Magic

  • An operating system kernel is a program
  • But, it makes the execution of other programs

possible!

  • This is a mind-expanding idea

– Sort of like recursion: a snake eating its own tail

  • Our belief: the operating system course should

be faithful to this idea

slide-4
SLIDE 4

4

How Are OS Projects Designed?

  • Many approaches out there:

– High level simulation [e.g., Dickinson SIGCSE 2000] – User mode process [e.g., Minix/Solaris]

  • Java?

– CPU simulator + user level threads [e.g., Nachos] – Emulator [e.g., System/161] – Real Hardware [e.g., Minix, Topsy]

slide-5
SLIDE 5

5

Our Approach

  • Target commodity hardware platform (x86 PC)
  • We provide minimal foundation, students build

real, complete OS on top of it

– Students add processes, VM, filesystem, IPC

  • Two motivations:

– Philosophical – Practical

slide-6
SLIDE 6

6

Philosophical Motivations

  • Targeting real hardware → 100% realism

– Peel away all layers of abstraction

  • Intellectual satisfaction

– “So that's how it works!”

  • Try it out on a real machine

– Students can do this at the end of the course!

slide-7
SLIDE 7

7

Practical Motivations

  • x86 fairly easy to program
  • Tool support is outstanding

– GCC, binutils, gdb, nasm – Bochs emulator

  • Lots of good documentation in books, on web
slide-8
SLIDE 8

8

Outline

  • Motivation
  • Overview
  • Projects
  • Classroom Experience
  • Conclusions
slide-9
SLIDE 9

9

GeekOS Facts

  • Project hosted at Sourceforge:

– http://geekos.sourceforge.net

  • Current version: 0.2.0
  • Free software (MIT license)
  • Includes manual with projects

– We do not publically distribute project solutions

slide-10
SLIDE 10

10

Overview of GeekOS

  • Written in C and x86 assembly
  • Size:

– Minimal configuration: 7100 lines – Maximal configuration (all drivers, VFS, buffer cache,

stubs for console, pipes, VM): 13300 lines

– All projects completed: 17000 lines

  • These figures include whitespace, comments,

assertions, debug statements

slide-11
SLIDE 11

11

GeekOS Features

  • Threads, memory allocation, drivers for essential

devices

  • VFS layer, read-only filesystem (for loading

programs), system call layer

  • Minimal C library, small collection of user

programs

  • Students add everything else!
slide-12
SLIDE 12

12

Outline

  • Motivation
  • Overview
  • Projects
  • Classroom Experience
  • Conclusions
slide-13
SLIDE 13

13

GeekOS and Bochs

  • We develop and run GeekOS using the Bochs

emulator:

– http://bochs.sourceforge.net

  • Advantages over running on actual hardware:

– Runs as ordinary user mode process – Boots in seconds – Extensive diagnostics, debugging with gdb

slide-14
SLIDE 14

14

Project 1—User Mode

  • Students add user processes using segmentation

for memory protection

– Programs loaded from ELF executables – Each process allocated a fixed, contiguous block of

memory

– Segmentation is easier than paging

slide-15
SLIDE 15

15

Project 2—Scheduling

  • Original scheduler is static priority, round-robin
  • Students implement

– Alternative scheduler with dynamic priorities – Semaphores

  • Students measure and evaluate both schedulers

under workloads we provide

– So they understand how the new scheduler addresses

shortcomings of the original scheduler

slide-16
SLIDE 16

16

Project 3—Virtual Memory

  • Students replace the segmentation-based user

mode with one based on paging

  • When no free pages are available, a victim is

selected using LRU and paged out

  • Page fault handler:

– Stack faults (add new page for accesses in red zone) – Page in previously evicted pages

slide-17
SLIDE 17

17

Project 4—Filesystem

  • Students implement a hierarchical read/write

filesystem

  • Students must handle locking for files and

directories accessed concurrently

slide-18
SLIDE 18

18

Project 5—Interprocess Communication

  • Students extend the VFS to include

– The console (keyboard and screen) – Pipes (anonymous, half-duplex, like Unix)

  • ACLs are added to the filesystem

– Each process gets a uid

slide-19
SLIDE 19

19

Demo

slide-20
SLIDE 20

20

Outline

  • Motivation
  • Overview
  • Projects
  • Classroom Experience
  • Conclusions
slide-21
SLIDE 21

21

Classroom Experience

  • Classroom experience has been positive

– Most students find GeekOS to be relatively easy to

work with

  • Using Bochs is a win

– Good diagnostics when things go wrong – Much easier than dealing with actual hardware

  • Lots of possibilities for alternative projects

– Combat plagarism

slide-22
SLIDE 22

22

Outline

  • Motivation
  • Overview
  • Projects
  • Classroom Experience
  • Conclusions
slide-23
SLIDE 23

23

Conclusions

  • Targeting real hardware platform is a viable

choice

– Intellectually satisfying – A good emulator makes it practical – Instructors can easily choose how “low-level” they

want students to get

– Students gain experience with system-level

programming

slide-24
SLIDE 24

24

Future Work

  • Fix bugs, improve documentation
  • Make GeekOS smaller and simpler
  • Port to a safe C dialect such as Cyclone

– Statically demonstrate absence of memory errors!

slide-25
SLIDE 25

25

Related Work

  • Minix (real hardware, complete OS)
  • Nachos (user process + CPU simulator)
  • OS/161 (emulator, close to real HW)
  • Topsy (microkernel, embedded MIPS target)
  • Many others...
slide-26
SLIDE 26

26

Questions?

slide-27
SLIDE 27

27

Feature Comparison

  • Of these, only Minix and GeekOS target

commodity hardware

OS Target Microkernel? Lines Minix x86, others Yes 32000 Nachos MIPS (CPU sim) No 9000 OS/161 MIPS (emulator) No 15000 Topsy MIPS (embedded) Yes 13000 GeekOS x86 PC No 13000

slide-28
SLIDE 28

28

Motivation

  • Why another educational OS?
  • We wanted two properties:

– Realism: target a real hardware platform – Simplicity: make it as simple as possible

  • Give students a feel for “real” kernel hacking

– Without overwhelming them with detail

slide-29
SLIDE 29

29

How is GeekOS Different?

  • GeekOS is different mainly in that

– It targets commodity hardware – It tries to be “minimal”

  • What we provide is merely a foundation

– Students build all of the interesting parts of the kernel

slide-30
SLIDE 30

30

Core Services

  • GeekOS provides the minimum functionality

needed to build higher level services:

– Memory allocation: page and heap – Interrupt handling – Threads (with preemptive task switching) – Device drivers: screen, keyboard, floppy, IDE disk – VFS layer, minimal read-only filesystem – System call layer

slide-31
SLIDE 31

31

GeekOS Userland

  • Minimal libc:

– Console I/O, file I/O, subprocess support, string

routines

  • Does not adhere to any standard API
  • Small set of user programs

– Shell, file and directory utils

slide-32
SLIDE 32

32

Projects

  • Students implement features of a modern kernel:

– Multilevel feedback scheduler – User processes with paged virtual memory – Read/write hierarchical filesystem – Pipes

  • When finished, resembles a simple version of

Unix

slide-33
SLIDE 33

33

x86 PC is a Good Platform

  • Targeting the x86 PC has many practical

benefits:

– Excellent tool support: Linux and FreeBSD come with

complete GeekOS-friendly toolchain installed by default

– x86 is easy to program – Lots of good documentation for system-level

programming