What an Operating System Actually Is
Two views of one program: the friendly face on top, the ruthless referee underneath
Ask ten engineers what an operating system is and you will get ten fuzzy answers: "it is Windows", "it is the thing that boots", "it is the kernel". None of these are wrong, but none of them are the whole picture either. The honest answer is that an OS is best understood from two directions at once, and holding both in your head is the single most useful mental model in this entire course.
Looked at from above — from where your code sits — the OS is an abstraction layer. It takes the ugly, model-specific reality of hardware and dresses it up as a small set of clean, portable ideas: files, processes, memory. You call open("data.txt") and never once think about which disk controller is attached or how its firmware wants to be poked.
Looked at from below — from where the hardware sits — the OS is a resource manager. One CPU, a few gigabytes of RAM, one disk, and dozens of programs that were never written to cooperate, all demanding those resources at the same time. The OS decides who gets what, when, and for how long — and enforces the rules so nobody cheats. This chapter makes that duality concrete and builds the vocabulary the rest of Part A depends on.
Two views of the same program
The trap most students fall into is picking one definition of an OS and clinging to it. The truth is that the operating system is doing two jobs simultaneously, and each job explains a different half of everything it does. Top-down it is an abstraction layer that hides hardware; bottom-up it is a resource manager that shares hardware. Same program, two faces.
Here is why both must be true at once. If the OS only abstracted hardware but did not manage it, two programs would happily write to the same disk sectors and corrupt each other. If it only managed resources but did not abstract them, every program would have to be rewritten for every disk, every network card, every CPU. You need the clean interface and the ruthless referee in the same box.
- Abstraction layer (top-down)
- The OS presents clean, portable concepts — files, processes, address spaces — so programs never touch raw hardware.
- Resource manager (bottom-up)
- The OS shares the CPU, memory, and devices among competing programs, deciding who gets what and when.
- Duality
- These are not two operating systems; they are two views of one program, and every OS feature serves one or both.
Mindset: For every OS feature you meet in this course, ask: is this here to give me a cleaner interface, to share a scarce resource, or both? The answer is almost always "both".
Abstraction: turning ugly hardware into clean ideas
Raw hardware is genuinely hostile to work with. A disk exposes numbered blocks and a controller with model-specific quirks; RAM is a flat sea of bytes with no notion of "your data" versus "mine"; the CPU is a single execution engine that knows nothing about programs. The OS abstraction layer exists to hide all of this behind a handful of ideas simple enough that an application developer never has to care.
Take three abstractions you use constantly. A process is the clean idea of a running program, layered over the raw CPU that really just executes one instruction stream at a time. An address space is the illusion of your own private, contiguous memory, layered over scattered physical RAM. A file is a named, growable stream of bytes, layered over fixed-size disk blocks you will never see. In each case the ugly thing is still down there — the OS just refuses to make it your problem.
- Process ↔ CPU
- A process is the abstraction of "a program in execution" sitting on top of a CPU that only understands raw instruction streams.
- Address space ↔ RAM
- Each program sees a private, contiguous range of addresses; the OS maps it onto physical memory that is neither private nor contiguous.
- File ↔ disk
- A file is a named byte stream; underneath, the disk knows only numbered blocks and the OS tracks which belong to which file.
- Portability
- Because the abstractions are stable, the same open()/read()/write() code runs unchanged across wildly different hardware.
Why engineers care: A database engine like Postgres is built almost entirely on these abstractions: it reads and writes files, maps memory, and spawns processes. It never talks to a disk controller — it trusts the OS to make "a file" behave like a file on every machine it ships to.
Resource management: sharing one machine among many
Flip the OS over and look at it from the hardware side. There is one CPU (or a handful of cores), one block of RAM, one disk — and far more programs than there are of any of these. The resource manager’s job is to multiplex: to share each scarce resource among all the programs so convincingly that each one behaves as if it had the machine to itself.
There are two fundamentally different ways to share. You can multiplex in time — give the CPU to one program for a few milliseconds, then snatch it back and hand it to the next, thousands of times a second. That is scheduling. Or you can multiplex in space — carve RAM into regions and give each program its own, all resident at the same time. That is memory allocation. On top of both sits arbitration and protection: the OS enforces that program A can neither read nor scribble on program B’s memory, so one crashing program cannot take down its neighbours.
- Time-multiplexing: the CPU is shared by slicing time — this is scheduling, done thousands of times a second.
- Space-multiplexing: RAM and disk are shared by dividing space — each program gets its own region at once.
- Fairness: the OS tries to give every program a reasonable turn, so no single process starves the rest.
- Isolation & protection: hard walls stop one program from corrupting or spying on another, enforced by hardware the OS configures.
Remember: When your server process gets killed by the Linux OOM killer, that is the resource manager at work: memory ran out, and the OS chose a victim to protect the rest of the system. It is not a bug — it is the referee making a hard call.
The kernel and the privilege line
For the OS to referee anything, it must have powers that ordinary programs do not. That trusted core is the kernel: the part of the OS that runs with full control over the hardware. Everything else — your app, your shell, even most of the system’s own tools — runs as unprivileged user code that must ask the kernel for anything dangerous.
This split is not enforced by good manners; it is enforced by the CPU itself. Modern processors run in at least two modes. In kernel mode, code may execute any instruction and touch any device. In user mode, the privileged instructions simply fail. When your program needs something only the kernel may do — open a file, allocate memory, send a packet — it performs a system call: a controlled, one-way door that switches the CPU into kernel mode, runs the trusted code, and switches back. The kernel checks every such request, which is exactly why one buggy program cannot corrupt the whole machine.
- Kernel
- The trusted core of the OS that runs in privileged mode and is the only code allowed to touch hardware directly.
- Kernel mode vs user mode
- Two CPU privilege levels: kernel mode can do anything; user mode blocks privileged instructions.
- System call
- The controlled doorway a user program uses to request privileged work from the kernel.
- Protection
- Because only the kernel is privileged and it checks every request, a faulty program can hurt itself but not its neighbours.
Depth ahead: We keep system calls light here on purpose — a whole later chapter traces one from your code, across the privilege line, into the kernel and back. For now, just hold the picture: user mode above the line, kernel mode below it.
The OS as an extended, virtual machine
Combine the two views and something elegant appears. The abstraction layer gives each program clean concepts; the resource manager gives each program its own share of the hardware. Put together, the effect is that every program runs as if it owns a private, simplified computer — its own CPU, its own memory starting at address zero, its own set of files. This illusion has a name: the OS presents each program with an extended (or virtual) machine that is nicer and simpler than the bare metal underneath.
This is why multitasking feels seamless. Your editor, your browser, and your build all believe they have the CPU to themselves, because the scheduler hands each of them slices so quickly that none notices the others. It is also why isolation feels automatic: since each program only ever sees its own virtual machine, one program simply has no way to name, reach, or corrupt another’s memory. The seams are hidden by design — and when they show (a stall, a swap, an out-of-memory kill) you are seeing the single real machine peek through the illusion.
- Extended machine
- The OS hands each program an interface that is richer and cleaner than raw hardware — the abstraction view, made personal.
- Virtual machine (illusion)
- Each program experiences a private, dedicated computer, though the real hardware is shared behind its back.
- Seamless multitasking
- Fast time-slicing makes many programs appear to run at once, each unaware of the others.
Gotcha: Do not confuse this everyday illusion with a full "virtual machine" like VMware or a cloud VM. Those virtualize the whole hardware so an entire OS can run inside — a heavier idea built on the same instinct, which we revisit near the end of the course.
Where operating systems live
The two-view model is not just a desktop story. The same core ideas — abstraction and resource management enforced by a privileged kernel — show up everywhere software runs, only the constraints change. A phone cares about battery and touch latency; a car’s brake controller cares about hard deadlines; a cloud host cares about packing many tenants safely onto one server. Different priorities, same skeleton.
- Desktop & server
- Linux, Windows, macOS — general-purpose OSes juggling many programs and users on rich hardware.
- Mobile
- Android (a Linux kernel) and iOS — the same ideas, tuned hard for battery life, touch, and app sandboxing.
- Embedded & RTOS
- Tiny OSes in routers, cars, and appliances; a real-time OS guarantees a response within a strict deadline.
- Cloud & hypervisor
- A hypervisor is an OS-like layer whose "programs" are entire guest operating systems, each in its own virtual machine.
Notice the recursion in that last one. A hypervisor multiplexes real hardware among several guest OSes exactly the way an OS multiplexes hardware among several programs — abstraction and resource management, one level up. The concepts you are about to learn scale from a thermostat to a data centre, which is precisely why they are worth learning deeply.
Looking ahead: That is the whole spine of the course in one chapter: abstraction, resource management, kernel and privilege, the virtual-machine illusion. The rest of Part A now zooms into the hardware the OS stands on and how a program actually becomes a running process.