Obstruction-free consensus

Processes try to agree on a value using only shared registers. Pick a scenario and step through every read and write. Read the algorithm

Model asynchronous  ·  atomic read/write registers  ·  any number of crash failures

t = 0  · 
0write 0read 0D or H ⊥empty (⊥) 0✓flag in B (✓ or ✗) 0decision crash

Shaded bands mark rounds, and the dashed vertical line marks the latest step. Click or tap a dot to inspect it. The line above the timeline then describes that step, its pseudocode line lights up, and for a read an arrow points back to the write it returned. Click it again, or click an empty spot, to go back to the latest step.

Shared registers

Custom runs

Custom setup
Input value of each process (what it proposes, 0–9)
Schedule: export, import, replay
A schedule lists every action in order. n means pn takes a step and xn means pn crashes. Export it to share an execution, or paste one in and press Load.

The algorithm

Algorithm 1  Obstruction-free consensus from commit-adopt objects, code for process pi
Shared registers (initially ⊥): D (decision) and H (round hint), both multi-writer; a commit-adopt object CAr (Algorithm 2) for each round r = 1, 2, … H = ⊥ is read as (0, ⊥).

Tags like p0 mark each process's next instruction. A faded p0 on line 8 means that process is inside Algorithm 2.

Algorithm 2  Commit-adopt object CAr [1], code for process pi
Specification. CAr.propose(v) returns (commit, w) or (adopt, w) such that
• Validity: w was proposed by some process.
• Coherence: if some process returns (commit, w), every process returns w (commit or adopt).
• Convergence: if all processes propose the same v, all return (commit, v).
• Obstruction-freedom: a process running alone returns (commit, v).
Shared registers (initially ⊥): Ar[1..n], Br[1..n], a fresh pair for each round r; Ar[i] and Br[i] are written only by pi.

Reading the diagram

Each process has its own row, with time running left to right. A dot is one atomic register operation, placed at the step where the scheduler (or your Step button) chose that process. A red ✕ marks a crash. The process takes no more steps, but the values it already wrote stay in the registers.

Sketch of correctness

Agreement. Within a round, two processes cannot both be flagged ✓ with different values. Each writes A before reading it, so whichever writes second sees the conflict. When a process commits v, every other process finishing that round either sees its ✓ or already holds v, so all of them move on with v and later rounds can only commit v. D and H only pass along values that processes already hold, and a crash just stops a process, so neither changes this.

Validity. A process only ever proposes its own input or a value it read from another process, so the decided value was always someone's input.

Termination. A process that runs alone eventually reaches a round nobody else has written to. It sees no conflict there and commits. While processes keep interleaving, nothing forces a decision (see Livelock).