---
title: "Physical vs logical clocks; Lamport"
subject: "Distributed System"
chapter: 5
key: "semester_7/distributed_system:lamport-physical-compare"
source: https://www.bctengineer.com/q/semester_7/distributed_system/lamport-physical-compare
site: BCT Engineering
---

# Physical vs logical clocks; Lamport

Distributed System · Chapter 5: Time and State in Distributed Systems

- Asked in: 2070 Asar, 2+6 marks
- Video: [Logical Clocks 🔥🔥](https://www.youtube.com/watch?v=nps88TsKFE4) — Perfect Computer Engineer
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_7/distributed_system/lamport-physical-compare
- Whole chapter: https://www.bctengineer.com/md/semester_7/distributed_system/chapter-5

## Question

Compare physical clocks and logical clocks with its implementation semantics. Describe Lamport's timestamp algorithm with its benefits and drawbacks.

## Short answer

Physical clocks measure real time and need synchronization; logical clocks are counters that only order events. Lamport's algorithm increments a counter before each event, attaches it to messages, and on receive takes max with the received timestamp plus one. Benefits: simple and small; drawback: C(a) < C(b) does not imply causality.

## Answer

#### Physical vs logical clocks
| Point | Physical clock | Logical clock |
|---|---|---|
| Measures | Real time (UTC) | Order of events only |
| Implementation | Hardware oscillator, synchronised by Cristian, Berkeley, NTP | Software counter (integer or vector) |
| Value meaning | Time of day | Count, no relation to real time |
| Drift | Drifts, needs periodic correction | No drift issue |
| Needs time server | Usually yes | No |
| Semantics | Event a before b if time(a) < time(b) | a → b implies C(a) < C(b) |
| Accuracy | Limited by network delay | Consistent with causality (exact, if and only if, only for vector clocks) |
| Use | Timestamps, billing, real-time tasks | Ordering, mutual exclusion, consistency |

#### Lamport's timestamp algorithm
Each process Pi has a counter Ci (initially 0).
1. Before every event, Ci = Ci + 1.
2. A message is sent with timestamp t = Ci.
3. On receipt of (m, t): Ci = max(Ci, t) + 1.

To get a total order, ties are broken by process id: (Ci, i).

Example: P1 sends m at C=3 (timestamp 3). P2 has C=1; on receipt P2 sets C = max(1,3)+1 = 4, so the receive is later than the send.

**Benefits**: simple; no physical clock needed; small overhead (one integer); gives an order consistent with causality; useful for distributed mutual exclusion and totally ordered multicast.

**Drawbacks**: C(a) < C(b) does not imply a → b; concurrent events cannot be identified (vector clocks fix this); no link with real time; a total order can be artificial.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. What is the main difference between a physical and a logical clock?
   A. Logical measures real time; physical only counts events
   B. Both need a time server
   C. Physical clocks never drift
   D. Physical measures real time; logical only orders events
   Answer: D. Logical clocks are counters with no relation to real time. (Key point: Physical vs logical)

2. P1 sends m with timestamp 3. P2 has C=1. What is P2's clock after receiving?
   A. 4
   B. 3
   C. 2
   D. 1
   Answer: A. max(1,3)+1 = 4, so the receive is after the send. (Key point: Lamport receive)

3. How does Lamport's scheme produce a total order of events?
   A. Use physical timestamps
   B. Compare (Ci, i), breaking ties by process id
   C. Use vector comparison
   D. Randomly order equal values
   Answer: B. Process id breaks ties. (Key point: Total order)

4. Which is a drawback of Lamport timestamps?
   A. They need heavy network traffic
   B. They drift from real time and need correction by NTP
   C. Concurrent events cannot be identified
   D. They cannot support mutual exclusion
   Answer: C. C(a) < C(b) does not imply a -> b, so concurrency is invisible. (Key point: Drawback)

## Related in Distributed System

- [Lamport's logical clock algorithm](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Alamport-clock) — Distributed System, chapter 5, asked 5×
- [Physical/logical clocks; NTP and Berkeley](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Aphysical-logical-ntp-berkeley) — Distributed System, chapter 5
- [Physical vs logical clock; sync method](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Aphysical-clock-sync-difficulty) — Distributed System, chapter 5, asked 2×
- [Physical clock synchronization algorithm](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Aphysical-clock-sync-algorithm) — Distributed System, chapter 5
- [Synchronising physical clock using logical clock](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Async-physical-with-logical) — Distributed System, chapter 5, asked 2×
- [Lamport algorithm for mutual exclusion](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Alamport-mutex) — Distributed System, chapter 6

## Related in other subjects

- [Logical and physical address bits](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Aresidence-monitor-address-bits) — Operating System, chapter 4
- [Structural model vs implementation model](https://www.bctengineer.com/question.md?key=semester_6%2Fobject_oriented_analysis_and_design%3Astructural-vs-implementation-model) — Object Oriented Analysis and Design, chapter 1
