LightMySky
En anglais

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.

No account needed. Progress saves in this browser.

What a learner can do afterwards

  • 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

1 · Read

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.

A sends m1B gets m1B sends m2C gets m2
Try it together

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.

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

Original instructional content authored for os-taxonomy.

2 · Watch

En anglais

Take it off screen

Print a worksheetA4 with an answer key page for grown-ups. No screen, no internet.

Where it sits

Then practise

8 questions wait behind this lesson, each with its answer explained. Every answer feeds the sky: stars light as they are learned, and dim when it is time to come back.

Spotted a problem on this page? Tell us
Clocks, Ordering and Happens-Before · Computing, ages 20 to 21 · LightMySky