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 Block→→Chandy-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 Zero → The Number Zero → Counting to Five → Counting to 10 → Counting to 20 → Counting a Set of Objects Up to 20 → Cardinality: The Last Number Counted → Matching Numerals to Quantities → Subitizing Small Quantities → Addition Within 10 → Number Bonds to 10 → Addition Within 20 → Doubles and Near Doubles → Doubles Facts Within 10 → Near Doubles Facts Within 20 → Mental Math Strategies for Addition → Mental Math: Adding and Subtracting Tens → Addition Within 100 → Repeated Addition as Multiplication → Multiplication as Equal Groups → Multiplication: Arrays → Basic Multiplication Facts (0s, 1s, 2s, 5s, 10s) → Multiplication Facts Within 100 → Division as Equal Sharing → Division as Grouping (Measurement Division) → Division: Grouping (Repeated Subtraction) Model → Division: Fair Sharing Model → Division as Equal Sharing → Division as Grouping → Basic Division Facts → Division Facts Within 100 → Multiplication and Division Fact Families → Relationship Between Multiplication and Division → Division Facts as Inverse of Multiplication → Remainders and Quotients in Division → Division Word Problems → Multi-Step Word Problems → Solving Multi-Step Word Problems → Multiplication Word Problems → Division Word Problems → Introduction to Long Division → Factors and Multiples → Prime and Composite Numbers → Equivalent Fractions → Relating Fractions and Decimals → Decimal Place Value → Integers and the Number Line → Comparing and Ordering Integers → Absolute Value → Adding Integers → Subtracting Integers → Multiplying Integers → Introduction to Exponents → Order of Operations → Integer Order of Operations → Variable Expressions → The Distributive Property → Variables and Expressions Review → Introduction to Polynomials → Adding and Subtracting Polynomials → Multiplying Polynomials → Factorial → Permutations → Combinations → Counting Principles: Addition and Multiplication Rules → Introduction to Graph Theory → Propositional Logic Foundations → Logical Equivalences → Boolean Algebra → Boolean Type and Truth Values → Comparison Operators and Boolean Tests → Logical Operators and Boolean Algebra → Boolean Algebra and Fundamental Laws → Logic Gates Fundamentals → Implementing Boolean Functions with Gates → Karnaugh Map Simplification → Combinational Circuit Design → Flip-Flops and Latches → Binary Counters: Design and Analysis → Binary Arithmetic → Fixed-Point Number Representation → Two's Complement Representation → Overflow and Underflow Detection → Binary Adders: Half-Adders and Full-Adders → Full Adder and Carry Propagation → Carry Lookahead Adder Design → Half Adder Circuit Design → Multiplication Circuit Design → Sequential Circuit Design → Registers and Register Files → Instruction Set Architecture (ISA) → Kernel Architecture and OS Structure → System Calls and User/Kernel Mode → Processes and the Process Control Block → Logical Clocks and Event Ordering

Longest path: 95 steps · 357 total prerequisite topics

Prerequisites (2)

Leads To (6)