---
title: "Physical clock synchronization algorithm"
subject: "Distributed System"
chapter: 5
key: "semester_7/distributed_system:physical-clock-sync-algorithm"
source: https://www.bctengineer.com/q/semester_7/distributed_system/physical-clock-sync-algorithm
site: BCT Engineering
---

# Physical clock synchronization algorithm

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

- Asked in: Model question
- Video: [Clock Synchronisation | Distributed Systems | Lec-49 | Bhanu Priya](https://www.youtube.com/watch?v=aiJTAqu4gxs) — Education 4u
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_7/distributed_system/physical-clock-sync-algorithm
- Whole chapter: https://www.bctengineer.com/md/semester_7/distributed_system/chapter-5

## Question

Define logical and physical clocks. How can you synchronize the physical clock in a distributed network, explain with suitable algorithm. Also make a comment on the algorithm if any and suggest the solution.

## Short answer

Physical clocks show real time and drift; logical clocks are counters for event ordering. The Berkeley algorithm synchronizes physical clocks: a master polls slaves for their times, averages them (discarding outliers), and sends each the adjustment amount. It avoids backward jumps but has a single point of failure; solution: elect a new master or use NTP with redundant servers.

## Answer

#### Logical and physical clocks
- **Physical clock**: a hardware clock showing real time. It drifts and must be synchronised to other clocks or to UTC.
- **Logical clock**: a software counter that orders events by the happened-before relation (Lamport, vector clocks); has no relation to real time.

#### Synchronising physical clocks: Berkeley algorithm
Used within a network with no machine having a UTC source (internal synchronisation).
1. A **master** (time daemon) is chosen.
2. The master periodically polls all slaves for their current time.
3. Each slave sends its time; the master corrects each value for the round-trip delay.
4. The master averages all the times (including its own, ignoring values that are far off).
5. It sends each machine the **amount by which to adjust** its clock (plus or minus), not the absolute time, so message delay does not matter. A clock that is ahead is slowed down, not set back.

Example: master 3:00, A 2:50, B 3:25; average = 3:05; adjustments: master +5 min, A +15, B −20.

(Another approach is Cristian's algorithm: ask a time server with a UTC receiver for the time and set T_new = T_S + RTT/2.)

#### Comment and solution
- The master is a **single point of failure**, and its polling is a bottleneck in large systems; a faulty master can corrupt all clocks.
- The result is the average of the nodes, not real UTC time, and accuracy is limited by variable delay.
- **Solution**: elect a new master by an election algorithm when it fails (bully/ring); discard outliers; or use **NTP**, with a hierarchy of redundant time servers connected to UTC (strata), which scales and tolerates failures.

## Check yourself

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

1. How does the Berkeley master compute the target time?
   A. Takes the largest clock
   B. Reads UTC
   C. Average of all clocks including its own, ignoring outliers
   D. Uses its own clock only
   Answer: C. Averages after correcting for round-trip delay. (Key point: Berkeley averaging)

2. Master 3:00, A 2:50, B 3:25. What is A's adjustment?
   A. +5 minutes
   B. -15 minutes
   C. -20 minutes
   D. +15 minutes
   Answer: D. Average 3:05; A at 2:50 moves up 15. (Key point: Example)

3. What is a weakness of the Berkeley algorithm?
   A. The master is a single point of failure
   B. It needs a UTC receiver
   C. It uses logical clocks
   D. It cannot adjust clocks
   Answer: A. Fix: elect a new master, reject outliers, or use NTP. (Key point: Weakness)

4. How does NTP overcome the problem?
   A. One central server
   B. Hierarchy of redundant servers connected to UTC
   C. Averaging only
   D. Vector clocks
   Answer: B. Strata give scalability and fault tolerance. (Key point: Solution)

## Related in Distributed System

- [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×
- [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's logical clock algorithm](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Alamport-clock) — Distributed System, chapter 5, asked 5×
- [Physical vs logical clocks; Lamport](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Alamport-physical-compare) — 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

## 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
- [Arithmetic versus logical IF](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Afortran-arithmetic-vs-logical-if) — Computer Programming, chapter 11, asked 3×
- [Logical and physical address bits](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Aresidence-monitor-address-bits) — Operating System, chapter 4
