How an operating system works
What the OS does for programs, the mode bit and system calls, how processes are created and moved between states, and how threads share memory and race.
About 6 hours of study
Learning objectives
- Explain user mode, kernel mode and the system-call path
- Follow a process through its states with a PCB and context switches
- Find a race condition in shared-memory code
Lessons
- 1
What an operating system does
The OS manages the hardware and gives programs simple abstractions. User mode and kernel mode, system calls, interrupts, booting and the kinds of kernel.
- 2
Processes
A process is a program in execution: its memory layout, its process control block, the five process states, context switches, and fork, exec and wait.
- 3
Threads and race conditions
Threads share a process's memory but each has its own stack. Why that makes count++ unsafe: a race condition you can cause yourself, step by step.
Module practice
- Privileged instructionsEasy
- System call tableMedium
- The mode bitHard
- Legal state changesEasy
- Dispatcher eventsMedium
- The process tableHard
- Speedup with threadsEasy
- Lost updatesMedium
- Replaying a schedule with a lockHard