TIME AND GLOBAL
STATES
PRESENTATION
GROUP 8
PRESENTATION BREAKDOWN
Synchronization
Casual Ordering of Messages
Global State and State Recording
SYNCHRONIZATION IN DISTRIBUTED SYSTEMS
Refers to the coordination of activities and sharing of information among multiple
nodes to ensure consistency and order in their operations.
Hardware clock – is a battery-backed clock that keeps track of the current time
and date even when the computer is powered off
However, hardware clocks are subjected to drift and as a result, any two clocks are likely
to be slightly different at any given time.
Clock skew- Instantaneous difference between the readings of any two clocks.
The same sourced clock signal arrives at different components at different times.
E.g.like the distance between two vehicles on the road
Clock drift- Crystal-based clocks count time at different rates and diverge.
Physical variations, temperature may affect e.g. the difference in speeds between
two vehicles on the road
CLOCK SYNCHRONIZATION METHODS
A non-zero clock skew implies clocks are not synchronised.
A non-zero clock drift causes skew to increases(eventually)
There are several methods for synchronizing physical clocks:
External Synchronization – Refers to the process of aligning the timekeeping of
multiple devices or systems using an external reference
Clocks synchronize to an external time source the Universal Coordinated Time(UTC)
UTC is the international time standard
Atomic clocks: based on the number of transitions per second of the cesium 133
atom which is pretty accurate
At present, the real time is taken as the average of some 50 cesium-clocks around
the world.
Introduces a leap second from time to time to compensate for days getting longer.
UTC is broadcast through short wave radio and satellite.
CLOCK SYNCHRONIZATION METHODS CONTINUED…
Internal Synchronization
Clocks synchronize locally
They are only synchronized with each other
There are two formal models of distributed systems: synchronous and
asynchronous.
Synchronous distributed systems have the following characteristics:
the time to execute each step of a process has known lower and upper bounds;
each message transmitted over a channel is received within a known bounded time;
each process has a local clock whose drift rate from real time has a known bound.
Asynchronous distributed systems, in contrast, guarantee no bounds on process
execution speeds, message transmission delays, or clock drift rates. Most
distributed systems we discuss, including the Internet, are asynchronous systems.
SYNCHRONIZATION ALGORITHMS
Centralized clock synchronization algorithms
Cristian’s algorithm
The Berkeley algorithm
The Network Time Protocol
Distributed algorithms
Global Averaging Distributed Algorithms
Localized Averaging Distributes Algorithms
THE BERKELEY ALGORITHM
• The Berkeley Algorithm is an algorithm for internal synchronization of a group of computers.
• Gusella and Zatti [1989] describe an algorithm for internal synchronization that they developed for collections
of computers running Berkeley UNIX.
• This algorithm assumes no machine has an accurate time and obtains average from participating computers.
• In it, a coordinator computer is chosen to act as the master and synchronizes all clocks to average and collects
clock values from the others computers (slaves ).
• The master uses round trip times to estimate the slaves’ clock values and takes an average (eliminating any
average round trip time with faulty clocks).
• It sends the required adjustment to the slaves (better than sending the time which depends on the round trip
time).
• • If the master fails, a new master is elected to take over (not in bounded time)
• Algorithm has provisions to ignore readings from clocks whose skew is to great.
THE BERKELEY ALGORITHM EXAMPLE
CAUSAL ORDERING OF MESSAGES
Refers to the establishment of a partial order among events in a
distributed system based on their casual relationship.
If event A casually (precedes) comes before event B (A → B), then the
ordering reflects that event A influenced or happened before event B
HAPPENED-BEFORE RELATIONSHIP
Happens Before is denoted by three rules
1.If a and b are events in the same process, and a comes before b, then
a → b. time(a)<time(b) using local clock
2.If a is the sending of a message by one process and b is the receipt of
the same message by another process, then a → b. send(m) → receive(m)
3.If a → b and b → c then a → c. (transitivity)
LAMPORT’S LOGICAL CLOCK
Is a concept introduced by computer scientist Leslie Lamport as a method for ordering events in a
distributed system
Timestamp – a value associated with an event or a message to represent its position in the logical
ordering of events
How do we assign logical timestamps to each event?
Timestamps obey causality
Rules:
Each process uses a local counter(clock) which is an integer
Initial value of counter is zero
Process increments its counter when a send or an instruction happens to it. The counter is assigned to
the event as its timestamp
A send message event carries its timestamp
For a receive (message) event the counter is updated by
max(local clock, message timestamp) + 1
LAMPORT’S LOGICAL CLOCK EXAMPLE
CONT…
There are some events which may not be causality and related
These are called concurrent events, they have the same timestamps
(C,F) and (H, C) are pairs of concurrent events
A pair of concurrent events doesn’t have a casual path from one event to
another(either way in he pair)
The purpose of a logical clock is not necessarily to maintain the same notion of
time as a reliable watch.
Instead, it is to keep track of information pertaining to the order of events
GLOBAL STATES
The global state of a distributed computation is the set of local states of all individual
processes involved in the computation plus the state of the communication channels.
It consists of the local state of each process, together with the messages that are currently in
transit, that is, that have been sent but not delivered.
Examples include:
Distributed garbage collection- An object is considered to be garbage if there are no longer
any references to it anywhere in the distributed system.
Distributed deadlock detection- A distributed deadlock occurs when each of a collection of
processes waits for another process to send it a message, and where there is a cycle in the
graph of this 'waits-for' relationship.
Distributed termination detection- The problem here is to detect that a distributed algorithm
has terminated. Detecting termination is a problem that sounds easy to solve: it seems at first
only necessary to test whether each process has halted.
Distributed Debugging
GLOBAL STATE AND STATE RECORDING