Lectures‎ > ‎


Acknowledgements: Some figures come from http://ospp.cs.washington.edu/. Some Notes come from http://pdos.csail.mit.edu/6.828/2014/schedule.html.

This Week

  • Course overview and logistics
  • Introductions
  • What is an operating system?
  • Some OS concepts


  • Operating systems are everywhere
  • They are essential to almost all computing devices
    • Small - sensors, mobile devices, tablets, etc.
    • Medium - laptops, desktops, servers
    • Large - supercomputers, the Internet
  • We will learn how operating systems are designed and implemented
  • We will learn by coding large parts of a real operating system


  • Desire to learn something complicated, something that not many people understand
    • Need to put in the time to learn
  • C and Parallel Programming (CS 220) or C and Systems Programming (CS 221)
    • Binary and hexadecimal representation
    • Pointers, structs, memory, data types
  • Data Structures and Algorithms (CS 245)
    • Linked lists, queues, trees, and hash tables
  • Good C programming skills
    • Most operating systems are written in C


  • My background - some OS history
  • Your name, OS and favorite editor for coding
  • Practice names

Final Exam Question

  • Give question in class.

Development Hardware: Raspberry Pi 3 Model B

Most of our work will be on the Raspberry Pi 3 Model B Single Board Computer:

This is an ARM-based (ARMv8/ARMv7) computer with GPU, USB, Ethernet, Audio, GPIO and more.
ARM processors are used in almost all mobile devices (iPhone, iPad, Android), there is a rumor that Apple is working on a ARM based laptop/desktop computer.
Everyone must purchase their own Raspberry Pi 3 model B

At a minimum you need
    A Raspberry Pi 3 B Single Board Computer
    USB TTL cable
    A USB power cable with a switch
    A case (highly recommended)
    An 8GB (or higher) micro sd cards (get high speed)
    Optional: USB ethernet adapter

Course Policies

  • Due dates and lateness
    • Late assignments will NOT be accepted
    • Turn in what you have for partial credit
    • Checkin to git regularly
    • Make sure you snapshot your working code (branches)
    • Make your own backups (DropBox, etc.)
  • Disputes only considered within 1 week of returned work
  • Missed exams: call or email me ahead of the exam
  • Class and lab attendance
    • Not required, but if you do come, come on time.
    • Exception: you must be present to take the quizzes.

How to do Well

  • Have fun!
  • Study all given source code
  • Do your own research on the Internet
  • Keep up: start the projects early
  • Learn by doing
  • Come to lecture and labs
  • Come to office hours (mine and the TAs)
  • Post questions and ideas
  • Ask lots of questions

What You Get

  • A deep understanding of how an OS works
  • How the OS kernel manages hardware
  • Relationships between applications and the OS
  • Kernel hacking experience
    • Can apply to Linux, BSD, Mac OS X, and Windows
  • UNIX systems programming
  • How to deal with concurrency
    • Needed in many apps, databases, games, servers, distributed systems
  • Debugging and problem solving skills

Lecture/Lab Format

  • Lecture (roughly)
    • 45 mins lecture
    • 10 mins break
    • 50 mins lecture (some coding)
  • Lab
    • Special coverage (usually looking at code)
    • Help with projects
    • Interactive grading

What is an Operating System

  • The OS is software that sits between applications and the hardware
  • Draw picture

Goals of an Operating System

  • Abstract hardware for convenience and portability
  • Multiplex the hardware among multiple applications
  • Isolate applications to contain bugs and malicious code
  • Allow sharing among applications

The Operating System Kernel

  • Most operating systems consist of special code that lives in memory.
  • This code is usually called the Operating System Kernel, or just Kernel.
  • The kernel runs in a privileged mode that has access special CPU instructions, all memory, and all devices.

OS Services

  • Processes (running applications)
  • Memory
  • Files
  • Directories
  • Time
  • Networking
  • Security
  • Much more

Some OS Tricks

  • Program loading and linking
    • E.g., clicking on Chrome, the OS does:
      • Transfers the executable file from disk to memory
      • Links the executables with required libraries
      • Some libraries may be in memory, some on disk
  • Running two or more programs at the same time
    • Many computers have only one processor
    • Multiple programs can run simultaneously
    • The OS must switch between programs allowing each to make progress
    • (Works on multi-core / multi-processor machines too)

More OS Magic

  • Programs expect a large, uniform address space
    • Perhaps need more more memory than physical memory
    • Disk space is used to augment physical memory
    • Is the OS is smart, infrequently used data will be pushed to or kept on disk
  • Storing Information
    • Files must be saved to or retrieved from disk
    • Must be able to easily locate files (hierarchy and search)
    • Must provide permissions on files and directories
    • Must be able to reuse freed disk space
    • Files must be exact
    • All of these operations must be fast

Conflicting Goals

  • Protection
    • Programs should not interfere with each other
      • Programs cannot touch each other's memory
      • One program cannot prevent another from running
    • Some files should not be accessible by others
  • Sharing
    • Programs need to share resources (e.g., network, disk, display, memory)
    • We want some files to be shared
      • All users can run the same "ls" program
      • Need shared read access to /etc/passwd, libraries

What is an OS? Definition

  • An extended machine
    • Programs utilize OS services through system calls
  • resource manager
    • The OS manages: CPU cycles, memory, disks, network cards, etc.
    • The OS provides multitasking or multiprogramming: multiple programs executing simultaneously on the same machine
  • In general, as OS is the software that bridges the gap between the hardware and application programs

What is an OS? OSPP Definition

  • Referee - manage shared resources among applications
  • Illusionist - provide an abstraction of the physical hardware
    • Dedicated CPU
    • Dedicated devices
    • A large contiguous address space
  • Glue
    • Common services that allow applications to work similarly and cohesively

Processes and System Calls

  • A huge OS abstraction is the Process
  • A process is a program in execution running in an isolated environment
    • It is given CPU time
    • It has memory
    • Access to files and I/O
  • The process can interact with the kernel using system calls
    • System calls allow an application to use kernel services
    • E.g., access a file, start a new process, make a network connection
  • See system calls in action:
    • Mac OS X: sudo dtruss <program>
    • On Linux: strace <program>
    • Consider hello_world and ls