Part 4 of 8 · 2 min read
Manager and interface
Think of a restaurant manager. The kitchen, the tables and the staff are limited, and many customers want them. The manager does not cook. The manager decides who gets which table, when, and keeps the customers from interfering with each other.
In plain words: The OS plays the same role for the resources of the machine: the processor, memory, disk space and devices. This is the "resource manager" view. Two ideas keep the work clear.
- A mechanism is how something is done. Example: the code that stops one program and starts another.
- A policy is which choice to make. Example: which program should run next when three are waiting.
Keeping the two apart lets an OS change its choices without rewriting its machinery. Later pages on scheduling and memory use this split again and again.
The OS also offers an interface that programs can call to ask for services: start a program, allocate memory, open a file, send data over the network. These calls are system calls. A typical OS provides a few hundred of them. Because they cover running programs, memory and devices, the OS is also described as providing a standard library to applications. Page 2 explains how a system call crosses into the OS.
A program that is running is called a process. A program on disk is a passive file. A process is that program in motion, with its own memory and its own place in the instruction sequence. The word is used here in a simple way, and Level 1 defines it fully.
Mechanism and policy
A mechanism is the low-level method that carries out an operation, and answers the question "how". A policy is the rule that decides which operation to perform or in what order, and answers the question "which". Keeping the two separate lets a system change its policy without rewriting its mechanism.
Example: switching the processor from one program to another is a mechanism. "Run the program that has waited longest" is a policy.
Check yourself: 1. Which is the restaurant manager's job in the analogy, cooking or deciding who gets a table? 2. Is "give each program 10 milliseconds in turn" a policy or a mechanism? 3. What is the difference between a program and a process?