Lecture 2

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 19

Lecture 2: OS Structure

CSC 469H1F Fall 2006 Angela Demke Brown

Week 1

Overview
Motivation: Why talk about structure? Kernel structures
Monolithic kernels Open systems Microkernels Kernel Extensions (Tuesday) Virtual Machines (Tuesday)

CSC469

Week 1

Motivation
Lets review what OS provides
Abstraction layers Protection boundaries Resource allocators Resource schedulers

Its complicated!

Windows NT ~29 million lines of code (as of 2000)

CSC469

Week 1

Monolithic OS
Apache
libc libpthread

Mozilla
libc libpthread

Emacs
libc

CPU Scheduling
Kernel

Interprocess Communication Networking File System Virtual Memory

Security CPU Network Memory Disk

CSC469

Week 1

Properties of Monolithic Kernels


OS is all in one place, below the red line Applications use a well-defined system call interface to interact with kernel Examples: Unix, Windows NT/XP, Linux, BSD, OS/161 Advantages?
Common in commercial systems
Good performance, well-understood, easy for kernel developers, high level of protection between applications No protection between kernel components, not (safely, easily) extensible, overall structure becomes complicated (no clear boundaries between modules)
Week 1

Disadvantages?

CSC469

Open Systems
Mozilla
Kernel and Applications

libpthread libc Interprocess Communication File System Virtual Memory

Apache

Emacs Networking

CPU

Network

Memory

Disk

CSC469

Week 1

Properties of Open Systems


Applications, libraries, kernel all in the same address space Crazy?
MS-DOS Mac OS 9 and earlier Windows ME, 98, 95, 3.1, etc. Palm OS and some embedded systems

Used to be very common Advantages?



CSC469

Very good performance, very extensible, works well for single-user OS No protection btwn kernel and/or apps, not very stable, composing extensions can lead to unpredictable behavior
Week 1

Disadvantages?

Microkernel OS
Mozilla libc libpthread Apache libc libpthread
Microkernel

Networking

Emacs libc

Processes Virtual Memory

File System

Interprocess Communication

CPU Scheduling

Security

CPU
CSC469

Network

Memory

Disk
Week 1

Properties of Microkernels
Design Philosophy: protected kernel code provides minimal small, clean, logical set of abstractions
Tasks and threads Virtual memory Interprocess communication

Everything else is a server process running at user-level Examples: Mach, Chorus, QNX, GNU Hurd Mixed results
CSC469 Week 1

Microkernel Advantages
Extensible: add a new server to add new OS functionality Kernel does not determine operating system environment
Allows support for multiple OS personalities Need an emulation server for each system (e.g. Mac, Windows, Unix) All applications run on same microkernel Applications can use customized OS (e.g. for databases)
CSC469 Week 1

More Advantages
Mostly hardware agnostic
Threads, IPC, user-level servers dont need to worry about underlying hardware

Strong protection
Even of the OS against itself (i.e., the parts of the OS that are implemented as servers)

Easy extension to multiprocessor and distributed systems

CSC469

Week 1

Microkernel Disadvantages
Performance
System calls can require a lot of protection mode changes (next slide)

Expensive to reimplement everything with a new model


OS personalities are easier to port to new hardware after porting to microkernel, but porting to microkernel may be harder than porting to new hardware See IBM Workplace OS story

Bad past history

CSC469

Week 1

Microkernel System Call Example


1. Application calls read(), traps to microkernel 2. microkernel sends message to Unix Personality requesting read 3. Unix personality sends message to File System Server (FSS) asking for data 4. FSS receives message and begins processing 5. FSS sends message to microkernel asking for disk blocks 6. Microkernel sends data back to FSS 7. FSS sends message to UNIX Personality with results 8. Unix Personality receives message with data 9. Unix Personality sends data to Application 10. Application receives data
CSC469

Application

UNIX Personality

File System Server (FSS)

Microkernel

Week 1

The Mach Microkernel


CMU Research Project The Plan:

Step 1: Proof of Concept Take BSD 4.1 and fix VM, threads, IPC Step 2: Microkernel and single-server Unix emulation Take unix kernel and saw it in half Step 3: Microkernel and multiple servers (for FS, paging, network, etc.) Servers glued together by modules that catch system calls
Week 1

CSC469

Mach
Reality:
Proof of concept completed in 1989 Unix server, SMP support, kernel threads, 5 HW architectures Commercial deployment: Encore Multimax, Convex Exemplar, OSF/1, NeXT (and eventually to OS X) Microkernel and single-server completed and deployed to 10s of machines Multi-server never fully completed

CSC469

Week 1

Key Mach Abstractions


Tasks/threads
Tasks are passive (address space + resources) Threads are active, perform computation

Ports

Message origin / destination Have access rights (embodied as capabilities) Essentially an object reference mechanism Basis of all communication in Mach

Messages

Devices Memory objects and memory cache objects


CSC469 Week 1

Tasks, threads and communication


Figure from Distributed Systems, Concepts and Design Coulouris, Dollimore & Kindberg Threads communicate by sending messages to ports of other threads. Network servers handle distributed communication transparently. On a multiprocessor userlevel threads are mapped to physical CPUs, providing true concurrency.

Network servers

Mach Uniprocessor Key: Port Task


CSC469

Mach Multiprocessor

Network

Thread Processor

Thread mapping Communications


Week 1

Mach External pager


Figure from Distributed Systems, Concepts and Design Coulouris, Dollimore & Kindberg Address space maps memory objects; microkernel maintains cache of memory object contents in physical memory while a user-level pager manages the backing store for each object. External pager may be on same, or different machine.

Tasks address space Region Messages

External pager Port

Memory cache objects Kernel


CSC469

Network Kernel
Week 1

Next Time
OS Extensions The Exokernel Virtual machines

CSC469

Week 1

You might also like