Reason about time and ordering
Distinguish wall-clock timestamps from causal order.
- Explain clock skew, logical ordering, and why timestamps alone do not prove causality.
Machines keep separate clocks, and those clocks drift or jump. Two events with close wall-clock timestamps may not have a reliable order. Lamport clocks provide a logical ordering rule: increment a local counter for each event, and when receiving a message set the counter to one more than the maximum of the local value and the received value. This preserves causal order, but does not measure elapsed time.
A Lamport timestamp can say that one event is ordered before another in the logical clock scheme. If you need to know whether two events are concurrent, a vector clock carries more information. Neither clock replaces synchronized time for deadlines.
Practice: run a Lamport clock by hand
Two rules cover everything:
- Local event or send: add 1 to your clock.
- Receive: take the larger of your clock and the message’s timestamp, then add 1.
Try it
Up to 15 XPWork out each timestamp
All clocks start at 0. Work out each new value before it’s revealed.
At the end, compare the last events on A and C. Their numbers can look ordered even when neither event could have affected the other.
- local event?
Practice: spot the skew
Try it
Up to 15 XPRead merged logs from two machines
These logs come from two servers, merged by timestamp. Something is impossible.
Which line can’t really have happened at the time it shows?
Key takeaways
Physical clocks can disagree.
Logical clocks track ordering, not elapsed duration.
Use monotonic time for local deadlines and timeouts.
Lesson quiz
5 questions · pass with 4 correct · up to 50 XP
Passing this quiz completes the lesson and keeps your streak going. Questions you miss come back in review sessions later.
Questions about this lesson
Stuck? Ask. Figured something out? Share it. Explaining is one of the best ways to learn.
Loading posts…