- Model question
Physical clock synchronization algorithm
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.
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.
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).
- A master (time daemon) is chosen.
- The master periodically polls all slaves for their current time.
- Each slave sends its time; the master corrects each value for the round-trip delay.
- The master averages all the times (including its own, ignoring values that are far off).
- 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.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Physical/logical clocks; NTP and Berkeley · Distributed System, chapter 5
- Physical vs logical clock; sync method · Distributed System, chapter 5 · asked 2×
- Synchronising physical clock using logical clock · Distributed System, chapter 5 · asked 2×
- Lamport's logical clock algorithm · Distributed System, chapter 5 · asked 5×
- Physical vs logical clocks; Lamport · Distributed System, chapter 5
- Need of logical clock synchronization · Distributed System, chapter 5
- Clock synchronization in DFS · Big Data Technologies, chapter 1
- Arithmetic versus logical IF · Computer Programming, chapter 11 · asked 3×
- Logical and physical address bits · Operating System, chapter 4