Foundations: What an Operating System Is

the hardware-software stack

It helps to picture a computer as a stack of layers, each resting on the one below and offering services to the one above — like floors of a building. At the very bottom is the hardware: the CPU, memory, disks, and devices, the physical machine that can only execute raw machine instructions. At the very top are the users and the application programs they run. The operating system is the crucial layer in between, and almost everything you do flows down through these layers and back up.

Reading top to bottom: a user interacts with an application (say a web browser); the application asks the operating system for services it cannot do itself, like reading a file or sending data over the network; the OS, through its kernel, drives the hardware to actually do the work; the hardware returns results back up the stack. Each layer talks only to its neighbors through a defined interface — applications use the system-call interface to reach the OS, and the OS uses device drivers and machine instructions to reach the hardware. This layering is why you can swap the layer above or below without rewriting everything: a new app runs on the same OS, and the same OS runs on new hardware.

Keeping the layers straight is the single most clarifying idea for a beginner. Many confusions vanish once you ask which layer something lives in: a virus is usually an application or kernel-level program, not hardware; a driver lives inside or beside the OS; a USB stick is hardware exposed to you as a file abstraction. The boundaries are not always perfectly clean — a hybrid kernel blurs internal layers, and virtualization can stack a whole guest OS on top of a host — but the mental model of hardware below, OS in the middle, applications above holds up remarkably well.

Saving a document: the word processor (application) calls write(); the OS kernel turns that into block writes; the disk controller (hardware) actually stores the bytes; an acknowledgment travels back up so the application can show you a saved checkmark. Four layers, one save.

A request flows down the stack to the hardware and a result flows back up.

Layer boundaries are conceptual aids, not iron walls. Real systems leak across them for speed (a database may manage its own caching), and virtualization deliberately stacks an OS on an OS — but the model is still the best starting map.

Also called
the layered view of a computersystem layers電腦的分層觀點