RTUComputer ScienceYr 2020 · Sem 82020

Q13Distributed Systems

Question

4 marks

How does the Berkeley algorithm achieve clock synchronization?

Answer

A critical mathematical exposition of the Berkeley Algorithm. Explains how an active Time Daemon violently polls distributed nodes, calculates the average physical drift, and forces catastrophic time corrections to synchronize the cluster without relying on external atomic clocks.

In a distributed system, physical quartz clocks drift wildly due to temperature and voltage variations. The Berkeley Algorithm completely abandons the requirement for an external, perfect atomic time server (like UTC). Instead, it relies strictly on mathematical averaging across the internal cluster to achieve relative synchronization.

  • 1. The Time Daemon: One physical machine is strictly elected as the master Time Daemon. It is not assumed to have the correct time; it is merely the mathematical orchestrator.
  • 2. The Polling Phase: The Daemon violently broadcasts a "Time Request" to all subordinate nodes in the cluster. It must mathematically calculate the round-trip network latency for every single node to ensure accurate offset calculations.
  • 3. The Mathematical Averaging: The nodes return their physical clock values. The Daemon calculates the mathematical average of all clocks (including its own). Crucially, it violently rejects "Faulty Clocks" (nodes whose time is wildly skewed by hours) to prevent the average from being catastrophically corrupted.
  • 4. The Correction Broadcast: The absolute genius of Berkeley. The Daemon DOES NOT broadcast the new exact time to the nodes. Because network latency is chaotic, broadcasting exact time causes further drift. Instead, it mathematically calculates the exact offset needed for each node. Example: It tells Node A, "You are too fast, mathematically slow your clock tick rate down by 15 milliseconds per second until you match the average."

By violently forcing clocks to slow down instead of jumping backward in time, the Berkeley algorithm prevents catastrophic software failures (like files suddenly having negative creation times or Make compilers crashing).

Back to Paper