---
title: "Synchronising physical clock using logical clock"
subject: "Distributed System"
chapter: 5
key: "semester_7/distributed_system:sync-physical-with-logical"
source: https://www.bctengineer.com/q/semester_7/distributed_system/sync-physical-with-logical
site: BCT Engineering
---

# Synchronising physical clock using logical clock

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

- Asked in: 2072 Kartik, 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/sync-physical-with-logical
- Whole chapter: https://www.bctengineer.com/md/semester_7/distributed_system/chapter-5

## Question

Why is it difficult to synchronize physical clock? Explain how clock synchronization can be solved using logical clock.

## Short answer

Physical clocks drift and message delays vary, making exact sync impossible. Logical clocks order events without real time: each process increments a counter per event, timestamps messages, and on receive sets its counter to max(local, received)+1, guaranteeing that if a happens before b, then C(a) < C(b).

## Answer

#### Why synchronising physical clocks is difficult
1. Each node has its own oscillator with a different drift rate, so clocks diverge continuously.
2. Message delay is unpredictable and variable (queueing, routing, congestion), so a received time value is already old, and delays in two directions may differ.
3. There is no shared global clock or memory.
4. Time servers and links can fail; clocks themselves can be faulty.
5. A clock cannot be moved backward without breaking ordering, so adjustment must be gradual.
6. Synchronisation must be repeated and costs network traffic in large systems.
Hence, perfect synchronisation is impossible; only a bounded error can be achieved.

#### Solving it using logical clocks
Most distributed applications need the **order** of events, not real time. Lamport observed that two processes need to agree on order only if they interact. Logical clocks give that order without any physical clock.

Using the happened-before relation (a → b if a precedes b in a process, or a is a send and b is its receive, plus transitivity):
1. Each process Pi keeps counter Ci, initially 0.
2. Increment Ci before every event.
3. A sent message carries timestamp t = Ci.
4. On receiving (m, t): Ci = max(Ci, t) + 1.
This guarantees a → b implies C(a) < C(b). If two events get the same value, order them by process id for a total order.

Example: P1 sends m at time 5. P2 with clock 2 receives it and sets its clock to max(2,5)+1 = 6, so receive is after send even though P2's local clock was behind. Thus no physical synchronisation is needed.

If concurrent events must be identified, use **vector clocks**. Logical clocks therefore solve ordering problems (mutual exclusion, replicated updates, totally ordered multicast) without synchronising the physical clocks; they cannot give the actual time of day.

## Check yourself

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

1. Why do physical clocks diverge continuously?
   A. The OS rewrites the time
   B. UTC changes constantly
   C. Messages carry wrong time
   D. Each node's oscillator has a different drift rate
   Answer: D. Different crystal rates cause drift. (Key point: Drift)

2. Why can logical clocks avoid physical synchronisation?
   A. Most applications need the order of events, not real time
   B. They keep real time more accurately
   C. They use a UTC server
   D. They stop clock drift
   Answer: A. Only interacting processes need to agree on order. (Key point: Idea of logical clocks)

3. P1 sends m at 5. P2 has clock 2. What is P2's clock after receipt?
   A. 5
   B. 6
   C. 3
   D. 7
   Answer: B. max(2,5)+1 = 6. (Key point: Receive rule)

4. What can logical clocks NOT provide?
   A. Event ordering
   B. Total order with ties broken by id
   C. The actual time of day
   D. Support for mutual exclusion
   Answer: C. They give order, not real time. (Key point: Limit)

## Close variants set in other exams

- [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×

## Related in Distributed System

- [Physical clock synchronization algorithm](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Aphysical-clock-sync-algorithm) — Distributed System, chapter 5
- [Need of logical clock synchronization](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Alogical-clock-sync-need) — Distributed System, chapter 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
- [Lamport's logical clock algorithm](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Alamport-clock) — Distributed System, chapter 5, asked 5×
- [Vector clock synchronization algorithm](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Avector-clock-algorithm) — Distributed System, chapter 5, asked 2×
- [Clock synchronization need; Lamport](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Aclock-sync-lamport-need) — Distributed System, chapter 5

## Related in other subjects

- [Clock synchronization in DFS](https://www.bctengineer.com/question.md?key=semester_8%2Fbig_data_technologies%3Aclock-synchronization-dfs) — Big Data Technologies, chapter 1
- [Logical and physical address bits](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Aresidence-monitor-address-bits) — Operating System, chapter 4
