# Berkeley algorithm

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/Berkeley_algorithm
> Markdown URL: https://mediated.wiki/source/Berkeley_algorithm.md
> Source: https://en.wikipedia.org/wiki/Berkeley_algorithm
> Source revision: 1044711244
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

Method of clock synchronisation

The **Berkeley algorithm** is a method of [clock synchronisation](/source/Clock_synchronisation) in [distributed computing](/source/Distributed_computing) which assumes no machine has an accurate time source. It was developed by Gusella and Zatti at the University of California, Berkeley in 1989.[1] Like [Cristian's algorithm](/source/Cristian's_algorithm), it is intended for use within [intranets](/source/Intranets).

## The algorithm

Unlike [Cristian's algorithm](/source/Cristian's_algorithm), the server process in the Berkeley algorithm, called the *leader*, periodically polls other *follower* processes. Generally speaking, the algorithm is:

1. A *leader* is chosen via an [election process](/source/Leader_election) such as [Chang and Roberts algorithm](/source/Chang_and_Roberts_algorithm).

1. The *leader* polls the *followers* who reply with their time in a similar way to [Cristian's algorithm](/source/Cristian's_algorithm).

1. The *leader* observes the [round-trip time](/source/Round-trip_time) (RTT) of the messages and estimates the time of each *follower* and its own.

1. The *leader* then averages the clock times, ignoring any values it receives far outside the values of the others.

1. Instead of sending the updated current time back to the other process, the *leader* then sends out the amount (positive or negative) that each *follower* must adjust its clock. This avoids further uncertainty due to RTT at the *follower* processes.

With this method the average cancels out individual clock's tendencies to drift. Gusella and Zatti released results involving 15 computers whose clocks were synchronised to within about 20-25 milliseconds using their protocol.

Computer systems normally avoid rewinding their clock when they receive a negative clock alteration from the leader. Doing so would break the property of monotonic time, which is a fundamental assumption in certain algorithms in the system itself or in programs such as [make](/source/Make_(software)). A simple solution to this problem is to halt the clock for the duration specified by the leader, but this simplistic solution can also cause problems, although they are less severe. For minor corrections, most systems slow the clock, applying the correction over a longer period of time.

Often, any client whose clock differs by a value outside of a given tolerance is disregarded when averaging the results. This prevents the overall system time from being drastically skewed due to one erroneous clock.

## References

1. **[^](#cite_ref-1)** Gusella, R.; Zatti, S. (1989), "The accuracy of the clock synchronization achieved by TEMPO in Berkeley UNIX 4.3BSD", *IEEE Transactions on Software Engineering*, **15** (7), IEEE: 847–853, [doi](/source/Doi_(identifier)):[10.1109/32.29484](https://doi.org/10.1109%2F32.29484)

---
Adapted from the Wikipedia article [Berkeley algorithm](https://en.wikipedia.org/wiki/Berkeley_algorithm) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/Berkeley_algorithm?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
