Part I · How it works
1. How the kernel works
- 1.1What does the kernel do?The kernel is the one program with full control of the hardware. It shares the CPUs, the memory and the devices among all the others.
- 1.2How the kernel shares the CPUsThere are more tasks wanting a CPU than CPUs, so the scheduler gives each a short turn, then switches: a context switch.
- 1.3How virtual memory worksEvery process sees its own memory, as if it were alone: the addresses it uses are virtual.
- 1.4Interrupts: how devices get attentionA device that needs the CPU (a packet arrived, a disk finished, a key was pressed) raises an interrupt: the CPU stops what it's doing and runs the kernel's handler for that device.
- 1.5How a program starts: fork and execA new process starts as a copy of an existing one: fork() duplicates the process that calls it.