O/S overview
Overview
Course goals:
Understand OS principles and their low-level design and implementation.
Exposure to non-trivial
Systems Programming
Analyzing xv6, a small Unix-like system comparable in structure to a common modern OS.
Designing and implementing a small OS with a somewhat different structure.
Build other skills crucial to effective programming, such as:
Clear, precise thinking about how software works
Reading, understanding, and building on code written by others
Collaborative design, development, and debugging
Sleuthing skills: finding subtle, non-obvious bugs
Why study operating systems?
Aren't Operating Systems commodity. Shouldn't we just treat them as black boxes?
High-performance servers are an OS issue
Resource consumption (CPU, Power, Memory, Disk) is an OS issue. Is my system slow, how to make it faster?
Security is an OS issue
Reliability is an OS issue: what causes crashes and how to fix
Scalability is an OS issue
Embedded Software is an OS issue
Understand engineering of large event-driven systems in general
OS evolution: step 0 (slide)
OS evolution: step 1 (slide)
OS evolution: step 2 (slide)
Protection
Goal: Isolate bad programs and people
Main Idea: Preemption + Interposition + Privilege Separation
Preemption: Give app something, can always take it away
Interposition:
OS between application and reality
Track all pieces that app allowed to use (usually in a table)
On every access, check in the table to check if access is legal
Privileged and Unprivileged mode
Apps unprivileged (peasant), OS privileged (god)
Protection operations can only be done in privileged mode. Can it be any other way?
Successful protection examples
Protecting CPU: pre-emption
Clock Interrupt: hardware periodically "suspends" app, invokes OS
OS decides when to take CPU away (scheduling)
CPU can also be taken away if (examples)
Process blocks
I/O completes
System calls. e.g.,
fd = open("/dev/foo", 1); write(fd, "hello\n", 6); pid = fork();
Protecting Memory: Address translation
Every load and store checked for legality
Typically use this machinery to translate to a new value. Why?
(Protecting Disk memory similar)
Translation allows Abstraction + Protection
Thread:
abstract CPU
Virtual memory:
abstract memory
File:
abstract disk/tape/flash/etc.
Pipe, Socket:
abstract communication wire
Why is OS design hard (and thus interesting)?
Tradeoff between fast/efficient and abstract/modular
Want to support many features with a few simple mechanisms
Interactions: e.g.,
fd = open(); ...; fork();
Many open problems: security, multi-core, distribution
Course structure
Lectures and Homeworks (20% of grade)
first, basic OS ideas
then extended inspection of xv6, a traditional O/S
finally, a series of recent topics
preparatory homework assignments - see schedule
due at beginning of lecture
no late homework accepted
grade based on homeworks and class participation
Labs (30% of grade, 10% bonus component): build a small 32-bit x86-based OS with threads, user processes, virtual memory, and a file system.
You build it in four labs, final project of your choice (bonus marks)
Kernel interface: only a few simple but powerful abstractions
Development environment: gcc, qemu, bochs
Extensive hacking: work in teams of up to 2
Labs due Thursdays at 11:59PM.
8 free late days, no credit for any lab more than 3 days late
Only Minor-1, no Minor-2 (20% of grade)
Open book, open notes
Major (30% of grade)
Open book, open notes
Reference materials
primary: draft xv6 book,
online
or from photocopy shop.
secondary: "Operating System Concepts"
other: see Reference section on home page