What an operating system does
◈ 5 cardsThe two views of an operating system, the six services it provides, and the users-by-processes taxonomy that puts UNIX in its box.
Two ways to look at the same thing
There are two honest descriptions of an operating system, and which one you reach for decides what you notice.
The bottom-up view calls the OS a resource manager. There is one CPU and forty processes that want it; there is a finite amount of RAM and every program would happily take all of it; there is one disk and a queue of requests arriving faster than the arm can move. From below, the operating system is the arbiter that hands those scarce things out fairly and keeps any one program from taking the lot.
The top-down view — the one this course adopts, and the one your exam answers should lead with — calls the OS a virtual machine. It is the layer that lets you say copy this file without knowing anything at all about the machine underneath. This is not a small claim, so it is worth taking apart.
Worked example: what cp memo letter actually costs you
You type five characters and a space and a word:
cp memo letter
Here is what you did not have to supply. You did not say which of the disks attached to the machine holds memo. You did not say which blocks on that disk it occupies, or whether those blocks are contiguous. You did not name a cylinder, a head, a sector, a logical block address or an erase block. You did not say whether the drive is a spinning platter, a SATA SSD or an NVMe device on the PCIe bus, and you did not load the driver for it. You did not allocate space for letter, or update the free-block accounting afterwards, or say what should happen if the machine loses power halfway.
All of that happened. The shell parsed your line and found the program. The kernel's file management turned the name memo into a set of disk blocks, and its disk management picked free blocks for letter and recorded that they are no longer free. The device driver for that particular hardware turned block requests into whatever electrical conversation that model of drive expects. The kernel's process management put your cp to sleep while the disk worked and gave the CPU to somebody else, then woke you up again.
You named two files. That gap — between what you had to know and what had to happen — is the operating system. Every service below is another instance of the same gap.
The six services
- Program execution — load a program, give it a CPU, clean up when it exits.
- I/O operations on behalf of programs — because a user program is never allowed to talk to hardware directly.
- Interprocess communication — pipes, named pipes (FIFOs) and sockets, so separate programs can be composed into one job.
- Error detection and reporting — a bad address, a full disk, a failed read; something has to notice and say so.
- File manipulation — create, open, read, write, delete, and the naming scheme that makes those possible.
- User management and security — who you are, what you own, and what you are permitted to touch.
Three kinds of operating system, and where the CPU goes when you block
Classify a system on two axes — how many users it serves at once, and how many processes it runs at once — and three practical combinations fall out. Single-user single-process systems (MS-DOS, the earliest Mac OS) do one thing for one person. Single-user multiprocess systems (a desktop Windows or OS/2 machine) do many things for one person. Multiuser multiprocess systems (UNIX, Linux, IBM's MVS) do many things for many people, and that is the box UNIX was designed for from the first week.
The mechanism that makes the third box work is multiprogramming: when the running process blocks — almost always waiting on I/O — the CPU is handed to another ready process instead of idling. Notice carefully what this improves. It does not make the blocked process finish sooner; that process is still waiting for the disk. It raises resource utilisation, and therefore throughput — the number of processes finished per unit time. That distinction is exactly what a well-set exam question probes.
One composition rule is worth memorising verbatim, because it is asked directly: a time-sharing system is multiuser + multiprocess + interactive. Drop the third term and you have described a batch system, which is multiprocess and multiuser and gives you no prompt at all.
Why UNIX is character-first
A graphical interface is an additional software layer between you and the same services. It is easier to discover and slower to drive, and it is very hard to write down. A character (command-line) interface is thinner: it is faster once learned, it gives you the full option surface of every command, and — decisively — a line you can type is a line you can put in a file and run again next Tuesday. UNIX is CUI-primary with a graphical system available on top, and that ordering is the reason this course is a typing course.