Structures

LWWRegister

The ranger needs one trail status before the morning bulletin. Alice reports open while Bob reports closed. Carol may receive either report first, but every notebook must choose the same answer.

The clock becomes part of the answer

A last-writer-wins register does not use message arrival order. It compares the timestamp attached to each write. If two writes have the same time, the greater writer ID breaks the tie.

WriterValueTimestamp
Alice · ATrail openT10
Bob · BTrail closedT10
WinnerTrail closedB breaks the tie
Carol gets the same winner even if the network delivers Alice's report last.
max(timestamp, writer ID)

One trail-status field

Choose one field report

Race equal-time reports from Alice and Bob. Delivery order changes nothing because each value includes the timestamp and writer ID.

Conflict rule Use the greatest timestamp; writer ID breaks a tie.

Alice

No status received

No status

Field note trail-status: Trail open time T10 · writer A

Bob

No status received

No status

Field note trail-status: Trail closed time T10 · writer B

Carol

No status received

No status

Field note No note in this race Carol observes delivery

Trail exchange Does not choose by arrival order 0 writes shared

Decision evidence No timestamped write yet.

  1. No writes shared yet.

Enable JavaScript to run the demo. The race and expected result remain in the lesson.

Race Alice's open report against Bob's closed report.

The losing report disappears

The rule gives the ranger one answer, but it cannot show whether Alice and Bob disagreed. If both reports are valid evidence, choosing a winner is too destructive. The next register keeps both concurrent values.

Sources and implementation

The demo follows Watershed's LWWRegister kernel and its timestamp-plus-author comparison rule.