The Operating-System Interface

the operating system and the kernel

Imagine a busy office building shared by hundreds of people who all want the same printer, the same meeting rooms, and the same front door. If everyone grabbed at the hardware directly it would be chaos. So the building hires a manager who owns all the shared equipment, hands it out fairly, and stops people from walking into each other's offices. On a computer, that manager is the operating system, and the strict, always-on core of it is the kernel.

More precisely: the operating system is the big collection of software that runs your machine - the kernel plus the shells, system services, and standard utilities around it. The kernel is the central program that is loaded when the machine boots and stays running until it shuts down. It is the only software allowed to touch the hardware directly: it decides which program runs on the CPU next, hands out memory, reads and writes the disk, and moves data over the network. Ordinary programs cannot do these things themselves; they must ask the kernel to do them on their behalf.

Why this split matters: because the kernel is the gatekeeper to the hardware, every interesting thing a program does - print to the screen, open a file, talk to the network - eventually becomes a request to the kernel. Understanding systems programming is largely about understanding that boundary: what a program is allowed to do on its own, and what it must ask the kernel for. People often say 'the OS' when they specifically mean 'the kernel'; the kernel is the privileged core, while 'operating system' is the whole package including non-privileged parts.

When your program calls printf("hi\n"), the text does not magically appear on screen. The C library eventually asks the kernel, via write(), to put those bytes on the terminal's output. Your program never touches the screen hardware itself - the kernel does.

Every hardware action a program wants ends up as a request to the kernel.

'Kernel' and 'operating system' are not exact synonyms: the kernel is the privileged core, while the OS is the whole bundle (kernel plus shells, libraries, and services). Saying 'the OS opened the file' really means 'the kernel did, on the OS's behalf.'

Also called
OSthe kernel作業系統核心