Lecture 1: Introduction
Overview
What's inside the modern OSes and why are they designed that way?
"Talk is cheap, show me your code" -Linus Torvalds
OS research and engineering have produced concepts and patterns that can be applied to user-space applications.
Related courses:
CS 211 Programming Practicum (C/C++)
CS 261. Machine Organization (Instructions, registers and memory, assembly language)
CS 251. Data Structures (Array and linked list)
CS 361. Systems Programming (*nix coding environment)
C & systems programming
Pointers
Stack/buffer overflow
Threads and concurrency
Signal handling and segmentation fault
Why modern OSes are getting so big?
There was no OS. On one machine, one program runs at a time.
https://en.wikipedia.org/wiki/Ken_Thompson#Career_and_research
More users, more tasks.
Multitasking: Resource and time sharing; Security protection.
"The update gave users the ability to keep certain apps running in the background while using others (for instance, playing music while reading a blog post)."
Device drivers, file systems, sound, camera, graphic interface, virtualization, etc..
One of the drive behind software evolution: engineers are lazy: minimum effort & maximum gain. Layers & components are gradually formed.
Kubernetes ("the operating system for the cloud", not really a traditional concept of OS)
Role of OS, from an user's perspective (hint: think of little kids)
"User: The machine is mine!"
"OS: I can make you feel like this until there is not enough available resources"
Example: OOM killer
Buzzword: thin-provisioning (why we need virtual machines and/or containers?)
On-demand resource allocation
(seemingly) continuous execution
Access control and protection
The abstraction: user and kernel modes
Interfaces: system calls, file system, exceptions, etc..
Example: User -- kernel -- File I/O (what's kernel bypass?)
What must be done in the kernel? What can be done at user mode?
Monolithic kernel vs. Micro kernel
Recommended reading: The Tanenbaum–Torvalds debate in 1992 (Before Linux!)
Figure: The Android architecture
Homework 1
A teaching operating system: xv6
A fully functional OS in 10k lines of code (mostly C, some x86 assembly).
Get started today!
The main purposes:
Get your coding environment ready.
Get a bit of taste of uncommon limitations in kernel programming.
Get familiar with the Linux command line environment and find yourself a handy text editor! (vim/emacs/sublime/nano/...)
We will have a brief tutorial for hw1 on Thursday.
Read the code and get started
x86-64 has everything in a flat directory:
kernel source code
user-space libraries and applications
the Makefile manages compilation for both the kernel and user programs
Read the Makefile to see what's the kernel code (search "OBJS" and "kernel"), and what's the user code (search for "UPROGS")
What's difference between fs.img and xv6.img?
$ make qemu # this will build everything needed and start a VM running an instance of the xv6-64 OS! Try it out with those provided commands "ls", "echo", etc..
The pop-up window looks useless. You can use $ make qemu-nox to run qemu without the graphic window. From the terminal, use "Ctrl+a, x" to exit emulation.