Part 2 of 8 · 2 min read
Answer structure
Think of explaining a route to a visitor: first say where it goes, then the way, then how long it takes, and then one landmark so they know they are right. A visitor who hears all four does not get lost. The analogy stops in one place: a route has one right answer, and a systems question often has trade-offs that depend on the case.
In plain words: A good answer to a systems question has four parts. Define the term in one sentence. Explain the mechanism: how it works, in two or three sentences. State the cost or trade-off: what it gains and what it risks. Give an example or a number: a case or a measurement that makes it real. The whole answer takes 30 to 60 seconds, and the interviewer can ask for depth at any part.
A worked example. Question: "What is a context switch?" Define: saving the state of the running thread and loading the state of another so that it runs. Mechanism: the kernel saves the registers and the program counter in the thread's record, picks the next thread (the scheduler, Level 3), switches the address space if it belongs to another process, and loads the new state (Level 1). Cost: the direct cost is small (microseconds), and the indirect cost is larger: the caches and the TLB are cold for the new thread (Level 6). Example: vmstat showed 43,854 context switches per second in the fsync test (page 4), which is a sign of many short waits.
The key lines. If you do not know, say what you do know, and reason from the mechanism. A wrong confident answer costs more than an honest partial one.
Trade-off
A trade-off is a choice in which an improvement in one property costs something in another, so that the best choice depends on the workload. Systems answers are strong when they name what is gained and what is paid.
Example: a longer time slice lowers context-switch overhead and raises response time for interactive tasks.
Check yourself: 1. What are the four parts of an answer? 2. Why name the cost of a design? 3. What should you do when you do not know an answer?