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

Lessons

  1. 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. 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. 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

Module quiz

1. Which part of the OS is always in memory and runs with full control of the hardware?
2. What happens when a program in user mode runs a privileged instruction?
3. What does fork() return in the parent process?
4. A process is waiting for a disk read when the CPU becomes free. What is its state?
5. Two threads both do count++ on a shared counter that starts at 0, with no lock. What can the final value be?
6. A program is 80% parallel. What is the speedup, by Amdahl's law, with 4 threads?

CPU scheduling ›