- CPU
- Registers
- General purpose.
- Program counter.
- Stack pointer.
- “Program Status Register”
- Program state.
- Saving and restoring state.
- Traps.
- Interrupts.
- Pipelines complicate the idea of the “current state”.
- Context switch.
- Change which program is running.
- Save the CPU registers and replace them with saved copies
from another running program.
- Traditionally a single CPU with a single thread of execution.
- Multi-threaded processor.
- Hyperthreaded is Intel's term.
- Multiple register sets.
- Multiple threads running on the CPU at once.
- CPU can switch between them rapidly without copying to memory.
- Multi-core. Essentially multiple CPUs on the same chip.
- Memory system.
- Addressing.
- Main memory.
- Cache.
- I/O
- Devices.
- Usually much slower than the CPU.
- Communication over buses.
- Disk buses: SATA now standard; older PC buses, SCSI, IDE
- General internal buses: PCIe (replaces PCI), previous ISA bus.
- External connections: USB. Previously RS232 serial or PC parallel.
- Note: This list often manages to get out of date.
- Storage devices.
- Mechanical disks.
- Slow.
- Operation order is important.
- Solid-State storage (flash).
- Reads are much faster than disks.
- Order doesn't matter.
- Writes wear the device, and must be distributed.
- I/O Device Communication
- CPU talks to devices by fetching and storing control
registers located in the device controller.
- The store or fetch may be used to trigger some action by the
device, as well as transferring a value.
- Two ways to address control registers.
- Memory mapped: assigned memory addresses.
- Port address space: own address space.
- Device Control
- Polling.
- Interrupts
- DMA
- Hardware Features Needed by the Operating System.
- Traps and interrupts. Allows the O/S to gain control.
- CPU modes: User and supervisor (or kernel) mode.
- Some instructions allowed only in supervisor mode.
I/O instructions, for instance.
- Traps and interrupts (including syscall) enter supervisory mode.
- Traditionally, a system call is performed by a trap.
- For performance reasons, the x64 architecture has a syscall
instruction. It does the same things as a trap, but it's
different configuration makes it cheaper to run.
- Switch to user before running user code.
- Reserves some operation to O/S kernel only.
- Memory Protection. Enforce allocations of memory.
- OS can't do this when user code is running.
- Creates an interrupt on violations.
- Clock interrupt. Preserves OS control.