---
title: "Clocks, Ordering and Happens-Before"
description: "Separate machines have separate clocks that drift, so a timestamp cannot settle which of two events came first. What can be settled is causality: one event happened before another if a message carried"
canonical: https://lightmysky.com/en/learn/computing/clocks-ordering-and-happens-before
source: https://lightmysky.com/learn/computing/clocks-ordering-and-happens-before.md
license: https://lightmysky.com/en/license
retrieved: 2026-12-03
---

> **Using this content.** You may index it, quote short parts, and use it to answer a person's question, if you name LightMySky and link to the page. You may train models on it.
> Please do not republish, resell or serve our lessons and questions as another product.
> [Topic data credits and licenses](https://github.com/withmarbleapp/os-taxonomy#attribution) (ODbL 1.0 for the database and CC BY-SA 4.0 for the topic text).
> Full license: https://lightmysky.com/en/license

> **Agent view.** This is the Markdown twin of the page, for tools and assistants.
> When to use this site, and the call that answers each job: https://lightmysky.com/agent-instructions.md
> API description (OpenAPI 3.1): https://lightmysky.com/openapi.json · Authentication: https://lightmysky.com/auth.md
> Pricing: https://lightmysky.com/pricing.md · Catalog: https://lightmysky.com/llms.txt · Full catalog: https://lightmysky.com/llms-full.txt
> Every machine-readable file on this domain: https://lightmysky.com/.well-known/ai-catalog.json
> Ask for Markdown with `Accept: text/markdown`, a `.md` address, or `?mode=agent`.

# Clocks, Ordering and Happens-Before

Separate machines have separate clocks that drift, so a timestamp cannot settle which of two events came first. What can be settled is causality: one event happened before another if a message carried information from the first to the second.

Subject: Computing · Area: Networks & Security · Ages 20 to 21
Page: https://lightmysky.com/en/learn/computing/clocks-ordering-and-happens-before

## Ready when they can

- Show two events on different machines whose order no clock can decide
- Use the happens-before relation to order the events that can be ordered
- Explain what a logical clock counts and what it does not measure

## Lesson: What clocks cannot tell you

When chat messages from two friends arrive in a mixed order, you wonder which came first. You already know machines exchange messages over a network. Each machine has its own clock, and those clocks drift apart. So a timestamp cannot settle which of two events on different machines came first.

What can be settled is causality. One event happened before another if a message carried information from the first to the second, possibly through middlemen. Here A sends to B, then B sends to C, so each step caused the next.

**Example.** Take a different setup where A and C never exchange messages, directly or through B. Their events have no definite order: no clock and no message chain decides it. Events like these are called concurrent, meaning unordered, not simultaneous.

A logical clock counts causal steps, not seconds. If one event caused another, the cause always has the lower count, so an event with a higher count cannot have caused one with a lower count. It never tells you what time anything happened. Passing one token round a ring links each handoff to the next, so rising counts mirror that order.

**Recap.** Drifting clocks cannot order distant events, but message chains define happened-before, and the rest is concurrent.

*Original instructional content authored for os-taxonomy.*

## Practice

8 questions on this page, each with its working shown.

## Needs first

- [The Web as a Protocol: Requests, State and Caching](https://lightmysky.com/en/learn/computing/the-web-as-a-protocol-requests-state-and-caching)

## Optional connections

- [Race Conditions and Mutual Exclusion](https://lightmysky.com/en/learn/computing/race-conditions-and-mutual-exclusion)

## Opens up

- [Failure Models and Replication](https://lightmysky.com/en/learn/computing/failure-models-and-replication)
- [Stream Processing: Windows, Watermarks and Late Events](https://lightmysky.com/en/learn/computing/stream-processing-windows-watermarks-and-late-events)
- [Impossibility Under Asynchrony: What Consensus Cannot Promise](https://lightmysky.com/en/learn/computing/impossibility-under-asynchrony-what-consensus-cannot-promise)
