---
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/learn/computing/clocks-ordering-and-happens-before-mt_ratia1eb_2
source: https://lightmysky.com/learn/computing/clocks-ordering-and-happens-before-mt_ratia1eb_2.md
retrieved: 2026-11-12
---

> **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/learn/computing/clocks-ordering-and-happens-before-mt_ratia1eb_2

## 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/learn/computing/the-web-as-a-protocol-requests-state-and-caching-mt_MDiW4Vt0bo)

## Optional connections

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

## Opens up

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