Tomasulo's algorithm lets instructions execute in whatever order their operands become ready.
Wonderful for speed — but it creates a crisis of accountability. Suppose a late instruction has already
written its result when an earlier instruction suddenly raises an exception (a page fault, a
divide-by-zero). The machine's architectural state is now a mess: a younger instruction's effects are
visible, but the older one never finished. How do you deliver a
The answer, from the late 1980s, is one of the most important structures in a modern CPU: the reorder buffer (ROB). The slogan is "execute out of order, but commit in order." Instructions may compute in any order they like, but their results are held in a waiting room and made architecturally official strictly in program order. The messy, speculative, out-of-order world is hidden inside the machine; the outside sees a tidy in-order sequence.
The trick is to separate speculative results from committed ones. When an instruction finishes executing, its result is not written straight into the architectural registers or memory. It goes into that instruction's ROB entry, where later instructions may still read it (via the same tag-forwarding as Tomasulo), but where it is officially "not real yet." Only when the instruction reaches the head of the ROB — meaning every older instruction has already committed — is its result written into the true architectural state. That final step is called commit or retire.
Physically the ROB is a ring of slots with two pointers. Newly issued instructions are appended at the tail (in program order); completed instructions are removed from the head (also in program order). Between the two pointers sit in-flight instructions in every state: some still executing, some finished-but-not-yet-committed. Because it's a ring, the pointers wrap around modulo the buffer size — no data ever moves, only the pointers advance. Each slot below is coloured by its state.
The ROB's mechanism is exactly the classic ring buffer: a fixed array with a head index, a tail index, and a count, all advancing modulo the capacity. Issue pushes at the tail; commit pops from the head. Run it and watch the indices wrap:
Now the payoff. Say instructions issue in order
The out-of-order execution is completely invisible to the exception handler. This same flush machinery is
exactly what makes
In the original ROB design, an instruction's result lives in its ROB entry while speculative and is copied into the architectural register file at commit — so a value can be read from two places depending on its age, and the commit step does real data movement. Modern high-end cores (Intel P6 onward, and every big core since) merged the two ideas with a physical register file: renaming already gave every result a physical register, so commit doesn't copy anything — it just updates a table saying "this physical register is now the architectural one," and frees the register the old value used. The ROB then holds only bookkeeping (which physical reg, is it done, did it fault), not the data itself. Same guarantee — in-order commit, precise state — with less copying.
Students sometimes fear that forcing in-order commit re-serialises everything and throws the speed away. It doesn't. The slow part — executing, waiting on memory and dependences — still happens fully out of order and overlapped. Commit is cheap: it just advances the head pointer and makes already-computed results official, several per cycle. As long as the oldest instruction eventually finishes, the whole train behind it retires in a quick burst. In-order commit costs you almost nothing in throughput and buys you precise exceptions and clean recovery — one of the great bargains in architecture.
The reorder buffer is the piece that makes aggressive out-of-order execution safe. It reconciles two things that seem incompatible: run instructions in any order for speed, yet present a strictly ordered, recoverable architectural state to the software. Its size is a headline design number — a big modern core keeps hundreds of instructions in flight in its ROB (Apple's cores famously have very large ROBs), because the more instructions you can hold, the further ahead you can look for independent work. And its flush-younger-entries mechanism is the universal "undo" button behind both exceptions and speculation.