A topic in the Open Knowledge Graph — a free, open map of 15,290 topics and the order to learn them in.

Logical Clocks and Event Ordering

Graduate Depth 94 in the knowledge graph I know this Set as goal
33topics build on this
357prerequisites beneath it
See this on the map →
Introduction to Distributed SystemsProcesses and the Process Control BlockChandy-Lamport Snapshot AlgorithmDistributed Snapshots and Consistent State Capture+4 more
time ordering causality

Core Idea

Without synchronized physical clocks, distributed systems need logical mechanisms to order events. Logical clocks assign monotonically increasing values to events based on message passing and local execution, capturing causal relationships and enabling detection of whether one event could have influenced another.

Explainer

In a single-threaded program on one machine, events have a natural order: whatever runs first happened first. You can look at wall-clock time and know exactly which instruction preceded which. In a distributed system, this breaks down completely. Each node has its own clock, and those clocks drift apart — sometimes by milliseconds, sometimes by seconds. If node A timestamps an event at 10:00:00.003 and node B timestamps an event at 10:00:00.001, you cannot conclude that B's event happened first. The clocks are simply not synchronized well enough to make that comparison meaningful.

Logical clocks solve this by abandoning wall-clock time entirely and instead tracking causality — the "could have influenced" relationship between events. The core insight, formalized by Leslie Lamport, is the happens-before relation: if event A occurs before event B on the same process, or if A is a message send and B is the corresponding receive, then A happens-before B. This relation is transitive: if A happens-before B and B happens-before C, then A happens-before C. Events with no happens-before path between them are concurrent — neither could have influenced the other.

A logical clock implements this by assigning each event a counter value. Every process maintains a local counter. When a process executes an event, it increments its counter. When it sends a message, it attaches the counter value. When it receives a message, it sets its counter to the maximum of its own counter and the received value, then increments. This ensures that if event A happens-before event B, then A's counter value is strictly less than B's. The converse is not necessarily true — two events may have ordered counter values yet be concurrent — which is why Lamport clocks capture a partial order rather than a total one.

Understanding logical clocks is essential because they underpin nearly every distributed algorithm you will encounter. Lamport timestamps extend this basic idea to create a total order (by breaking ties with process IDs). Vector clocks go further, giving each process its own counter dimension so you can detect concurrency precisely. But the foundation is always the same: replace unreliable physical time with a counter discipline that faithfully tracks causality through message passing.

Practice Questions 5 questions

Prerequisite Chain

Understanding ZeroThe Number ZeroCounting to FiveCounting to 10Counting to 20Counting a Set of Objects Up to 20Cardinality: The Last Number CountedMatching Numerals to QuantitiesSubitizing Small QuantitiesAddition Within 10Number Bonds to 10Addition Within 20Doubles and Near DoublesDoubles Facts Within 10Near Doubles Facts Within 20Mental Math Strategies for AdditionMental Math: Adding and Subtracting TensAddition Within 100Repeated Addition as MultiplicationMultiplication as Equal GroupsMultiplication: ArraysBasic Multiplication Facts (0s, 1s, 2s, 5s, 10s)Multiplication Facts Within 100Division as Equal SharingDivision as Grouping (Measurement Division)Division: Grouping (Repeated Subtraction) ModelDivision: Fair Sharing ModelDivision as Equal SharingDivision as GroupingBasic Division FactsDivision Facts Within 100Multiplication and Division Fact FamiliesRelationship Between Multiplication and DivisionDivision Facts as Inverse of MultiplicationRemainders and Quotients in DivisionDivision Word ProblemsMulti-Step Word ProblemsSolving Multi-Step Word ProblemsMultiplication Word ProblemsDivision Word ProblemsIntroduction to Long DivisionFactors and MultiplesPrime and Composite NumbersEquivalent FractionsRelating Fractions and DecimalsDecimal Place ValueIntegers and the Number LineComparing and Ordering IntegersAbsolute ValueAdding IntegersSubtracting IntegersMultiplying IntegersIntroduction to ExponentsOrder of OperationsInteger Order of OperationsVariable ExpressionsThe Distributive PropertyVariables and Expressions ReviewIntroduction to PolynomialsAdding and Subtracting PolynomialsMultiplying PolynomialsFactorialPermutationsCombinationsCounting Principles: Addition and Multiplication RulesIntroduction to Graph TheoryPropositional Logic FoundationsLogical EquivalencesBoolean AlgebraBoolean Type and Truth ValuesComparison Operators and Boolean TestsLogical Operators and Boolean AlgebraBoolean Algebra and Fundamental LawsLogic Gates FundamentalsImplementing Boolean Functions with GatesKarnaugh Map SimplificationCombinational Circuit DesignFlip-Flops and LatchesBinary Counters: Design and AnalysisBinary ArithmeticFixed-Point Number RepresentationTwo's Complement RepresentationOverflow and Underflow DetectionBinary Adders: Half-Adders and Full-AddersFull Adder and Carry PropagationCarry Lookahead Adder DesignHalf Adder Circuit DesignMultiplication Circuit DesignSequential Circuit DesignRegisters and Register FilesInstruction Set Architecture (ISA)Kernel Architecture and OS StructureSystem Calls and User/Kernel ModeProcesses and the Process Control BlockLogical Clocks and Event Ordering

Longest path: 95 steps · 357 total prerequisite topics

Prerequisites (2)

Leads To (6)