0% found this document useful (0 votes)
37 views4 pages

Physical Clock Synchronization

The document discusses physical and logical clock synchronization in distributed systems, emphasizing the need for accurate timekeeping and event ordering. It outlines methods for physical clock synchronization, such as UTC and algorithms like Christian's and Berkely's, while introducing logical clocks for maintaining event order based on causality. The Lamport clock algorithm is highlighted as a practical implementation of logical clocks, allowing for consistent event ordering despite the challenges of maintaining synchronized physical clocks.

Uploaded by

nehrusowmi94
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views4 pages

Physical Clock Synchronization

The document discusses physical and logical clock synchronization in distributed systems, emphasizing the need for accurate timekeeping and event ordering. It outlines methods for physical clock synchronization, such as UTC and algorithms like Christian's and Berkely's, while introducing logical clocks for maintaining event order based on causality. The Lamport clock algorithm is highlighted as a practical implementation of logical clocks, allowing for consistent event ordering despite the challenges of maintaining synchronized physical clocks.

Uploaded by

nehrusowmi94
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Physical Clock Synchronization:

 In physical clock synchronization, All the computers will have their own clocks.
 The physical clocks are needed to adjust the time of nodes. All the nodes in the system can share
their local time with all other nodes in the system.
 The time will be set based on UTC (Universal Coordinate Timer).
 The time difference between the two computers is known as “Time drift”. Clock drifts over the
time is known as “Skew”. Synchronization is necessary here.

Physical clocks: In physical synchronization, physical clocks are used to time stamp an event on
that computer.
If two events, E1 and E2, having different time stamps t1 and t2, the order of the event occurring
will be considered and not on the exact time or the day at which they are occur.

Several methods are used to attempt the synchronization of the physical clocks in Distributed
synchronization:

1. UTC (Universal coordinate timer)


2. Christian’s algorithm
3. Berkely’s algorithm

Logical clock and Logical time


Logical time
The logical time in distributed systems is used to maintain the consistent ordering of events. The
concept of causality, i.e. the causal precedence relationship, is fundamental for distributed
systems. Usually, it is tracked using physical time, but physical clocks are hard to maintain in a
distributed system, so logical clocks are used instead. The idea that makes logical clocks
different is that these are designed to maintain the information about the order of events rather
than pertaining to the same notion of time as the physical clocks.

Rules

A logical clock must specify the following two rules to implement proper functionality:

 Rule 1 determines how a local process updates its clock when an event occurs.
 Rule 2 determines how a local process updates its global clock upon receiving a message
from another process to update its view of global time.

Lamport clock algorithm


Lamport clock is a simple logical clock implementation. The illustration above shows the
working of Lamport clock algorithm

P1
P2 P3
C1=2
C2=3 C3=1

a C(a)=1 Physical time


d

C(b)=2 C(m)=2

b
m c

Defining the happens-before relation

An event is something happening at a server node (sending or receiving messages, or a local


execution step). If an event a happens before b, we write it as a -> b.

There are three conditions in which we can say an event a happens before b:

 If it is the same node and a occurs before b, then a -> b


 If c is a message receipt of b, then b -> c
 Transitivity: If a -> b and b -> c, then a -> c

A happens-before relation does not order all events. For instance, the events a and d are not
related by ->. Hence, they are concurrent. Such events are written as a || d.

Implementing Lamport clocks

Lamport clocks tag events in a distributed system and order them accordingly. We seek a clock
time C(a) for every event a. The clock condition is defined as follows:

If a -> b, then C(a) < C(b).

Each process maintains an event counter. This event counter is the local Lamport clock.
The Lamport clock algorithm works in the following way:

 Before the execution of an event, the local clock is updated. This can be explained by the
equation Ci = Ci+1, where i is the process identifier.
 When a message is sent to another process, the message contains the process’ local clock,
Cm.
 When a process receives a message m, it sets its local clock to 1+max(CI, Cm).

 In the example above, all local clocks start from a value of 0. Before the execution of an
event, the local clock increments by 1. Notice that P2’s clock starts from 0, but on the
arrival of the message m1 from P1, it updates its clock in accordance with the third rule
mentioned above, i.e., 1+max(Ci, Cm) where Ci = 0 and Cm = 2.
 Hence, P2’s final clock value is 3.
 Note: d is an event on P3, so, C(d) = 1, where d is parallel to a.

Applications

Logical time has many applications in distributed systems.

 It is used to resolve conflicts, track individual events, and take concurrency measures.
 Logical time also has its application in debugging distributed systems. With all the
information about the causal relationship of events, it is easy to spot which event caused
the error.

Logical Clocks

 Logical Clocks refer to implementing a protocol on all machines within your


distributed system, so that the machines are able to maintain consistent ordering of
events within some virtual timespan. A logical clock is a mechanism for capturing
chronological and causal relationships in a distributed system. Distributed systems may
have no physically synchronous global clock, so a logical clock allows global ordering
on events from different processes in such systems.
 Example :
If we go outside then we have made a full plan that at which place we have to go first,
second and so on. We don’t go to second place at first and then the first place. We
always maintain the procedure or an organization that is planned before. In a similar
way, we should do the operations on our PCs one by one in an organized way.
 Suppose, we have more than 10 PCs in a distributed system and every PC is doing it’s
own work but then how we make them work together. There comes a solution to this
i.e. LOGICAL CLOCK.
 Method-1:
Method-1:
To order events across process, try to sync clocks in one approach.

This means that if one PC has a time 2:00 pm then every PC should have the same time which
is quite not possible. Not every clock can sync at one time. Then we can’t follow this method.
Method-2:
Another approach is to assign Timestamps to events.
Taking the example into consideration, this means if we assign the first place as 1, second
place as 2, third place as 3 and so on. Then we always know that the first place will always
come first and then so on. Similarly, If we give each PC their individual number than it will be
organized in a way that 1st PC will complete its process first and then second and so on.
BUT, Timestamps will only work as long as they obey causality.
What is causality ?
Causality is fully based on HAPPEN BEFORE RELATIONSHIP.
 Taking single PC only if 2 events A and B are occurring one by one then TS(A) < TS(B). If
A has timestamp of 1, then B should have timestamp more than 1, then only happen before
relationship occurs.
 Taking 2 PCs and event A in P1 (PC.1) and event B in P2 (PC.2) then also the condition
will be TS(A) < TS(B). Taking example- suppose you are sending message to someone at
2:00:00 pm, and the other person is receiving it at 2:00:02 pm.Then it’s obvious that
TS(sender) < TS(receiver).
Properties Derived from Happen Before Relationship –
 Transitive Relation –
If, TS(A) <TS(B) and TS(B) <TS(C), then TS(A) < TS(C)
 Causally Ordered Relation –
a->b, this means that a is occurring before b and if there is any changes in a it will surely
reflect on b.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy