SlideShare a Scribd company logo
1
NEED??
• Time driven systems: in statically scheduled systems
activities are started at "precise" times in different points of
the distributed system.
• Time stamps: certain events or messages are associated with
a time stamp showing the actual time when they have been
produced; certain decisions in the system are based on the
"exact" time of the event or event ordering.
• Calculating the duration of activities: if such an activity starts
on one processor and finishes on another (e.g. transmitting a
message), calculating the duration needs clocks to be
synchronized.
2
 It is impossible to guarantee that physical
clocks run at the same frequency
 Lack of global time, can cause problems
 Example: UNIX make
◦ Edit output.c at a client
◦ output.o is at a server (compile at server)
◦ Client machine clock can be lagging behind the
server machine clock
When each machine has its own clock, an event
that occurred after another event may
nevertheless be assigned an earlier time.
• Every computer is equipped with CMOS clock circuit.
These are electronic devices that count oscillations
occurring in a crystal.
• Also called timer, usually a quartz crystal, oscillating at
a well defined frequency.
• Timer is associated with two registers: A Counter and
a Holding Register, counter decreasing one at each
oscillations.
• When counter reaches zero, an interrupt is generated;
this is the clock tick.
• Clock tick have a frequency of 60-100 ticks per
second.
5
• The problems:
1. Crystals cannot be tuned perfectly. Temperature and other
external factors can also influence their frequency.
Clock drift: the computer clock differs from the real time.
2. Two crystals are never identical.
Clock skew: the computer clocks on different processors of
the distributed system show different time.
6
☞ Distributed Algorithms
• There is no particular time server.
• The processors periodically reach an agreement on the
clock value by averaging the time of neighbors clock and
its local clock.
-This can be used if no UTC receiver exists (no external
synchronization is needed). Only internal
synchronization is performed.
- Processes can run on different machines and no global
clock to judge which event happens first.
7
• Cristian’s Algorithm is centralized algorithm.
 The simplest algorithm for setting time, it issues a Remote
Procedure Call to time server and obtain the time.
 A machine sends a request to time server in “d/2” seconds,
where d=max difference between a clock and UTC.
 The time server sends a reply with current UTC when
receives the request.
 The machine measures the time delay between time
server sending the message and machine receiving it.
Then it uses the measure to adjust the clock.
8
 The best estimate of message propagation time= (T0 + T1)/2
 The new time can be set to the time returned by server plus time
that elapsed since server generated the timestamp:
Tnew = Tserver + (T0 + T1)/2
9
• It is also a Centralized algorithm and its Time server is an
Active Machine.
 The server polls each machine periodically, asking it for
the time.
 When all the results are in, the master computes the
average time.
 Instead of sending the updated time back to slaves, which
would introduce further uncertainty due to network delays,
it sends each machine the offset by which its clock needs
adjustment.
 If master machine fails, any other slave could be elected
to take over.
10
a) The time daemon sends synchronization query to other
machines in group.
b) The machines sends timestamps as a response to query.
c) The Server averages the three timestamps and tells everyone
how to adjust their clock by sending offsets.
11
• NTP is an application layer protocol
• Default port number 123
• Uses standard UDP Internet transport protocol
• Adjust system clock as close to UTC as possible
over the Internet.
• Enable sufficiently frequently resynchronizations.
(scaling well on large num
• The NTP service is provided by a network of servers
located across the Internet.
• Primary servers are connected directly to a time
source. (e.g. a radio clock receiving UTC, GPS).
bers of clients and servers)
12
 Secondary servers are synchronized with primary
servers.
 The servers are connected in a logical hierarchy
called a synchronization subnet. Each level of the
synchronization subnet is called stratum.
13
 A requests time of B at its own T1
 B receives request at its T2, records
 B responds at its T3, sending values of T2 and T3
 A receives response at its T4
 Question: what is θ = TB – TA?
Synchronization in
Distributed SystemsCS-4513 D-term 2008
14
A
B
T1
T2 T3
T4
 Question: what is θ = TB – TA?
 Assume transit time is approximately the same both
ways
 Assume that B is the time server that A wants to
synchronize to
Synchronization in
Distributed SystemsCS-4513 D-term 2008
15
A
B
T1
T2 T3
T4
( ) ( )2314 TTTT −−−
 A knows (T4 – T1) from its own clock
 B reports T3 and T2 in response to NTP
request
 A computes total transit time of
Synchronization in
Distributed SystemsCS-4513 D-term 2008
16
A
B
T1
T2 T3
T4
( ) ( )
2
2314 TTTT −−−
( ) ( )
2
2314
3
TTTT
T
−−−
+
 One-way transit time is approximately ½ total,
i.e.,
 B’s clock at T4 reads approximately
Synchronization in
Distributed SystemsCS-4513 D-term 2008
17
A
B
T1
T2 T3
T4
 Servers organized as strata
◦ Stratum 0 server adjusts itself to WWV directly
◦ Stratum 1 adjusts self to Stratum 0 servers
◦ Etc.
 Within a stratum, servers adjust with each other
CS-4513 D-term 2008
Synchronization in Distributed
Systems 18
LogicaL cLocks
19
 Assume no central time source –
 Each system maintains its own local clock .
 No total ordering of events .
 Allow to get global ordering on events.
 Assign sequence numbers to messages –
 All cooperating processes can agree on order
of event.
20
• It is used to provide a partial ordering of events
with minimal overhead.
• It is used to synchronize the logical clock.
• It follows some simple rules:
 A process increments its counter before each event in
that process i.e. Clock must tick once between every two
events.
 When a process sends a message, it includes its
timestamp with the message.
 On receiving a message, the receiver process sets its
counter to be the maximum of the message counter and
increments its own counter .
21
 a ‘Happened Before’ b : a→b
1. If a and b are events in the same process, and a
comes before b, then a → b.
2. If
a :message sent
b : receipt of the same message
then a → b.
1. Transitive: If a → b and b → c then a → c.
2. Two distinct events a and b are said to be concurrent
if a -/->b and b -/->a
22
Figure 6-9. (a) Three processes, each with its own clock.
The clocks run at different rates.
 For two events a and b in same process p1
 C(b)= C(a)+1
 If a is sending process and b is receiving process
of pi and pj then,
 Cj(b)=max((Ci(a)+1),Cj(b))
24
Lamport’s algorithm corrects the clocks.

More Related Content

What's hot (20)

PDF
8. mutual exclusion in Distributed Operating Systems
Dr Sandeep Kumar Poonia
 
PPTX
Message and Stream Oriented Communication
Dilum Bandara
 
PPTX
Synchronization in distributed computing
SVijaylakshmi
 
PPT
Chapter 4 a interprocess communication
AbDul ThaYyal
 
ODP
Distributed operating system(os)
Dinesh Modak
 
PPT
clock synchronization in Distributed System
Harshita Ved
 
PDF
Distributed deadlock
Md. Mahedi Mahfuj
 
PPTX
Concurrency Control in Distributed Database.
Meghaj Mallick
 
PPTX
Inter Process Communication
Adeel Rasheed
 
PPTX
Processor allocation in Distributed Systems
Ritu Ranjan Shrivastwa
 
PPT
distributed shared memory
Ashish Kumar
 
PPTX
Transport layer
reshmadayma
 
PDF
Mobile computing (Wireless) Medium Access Control (MAC)
Jyothishmathi Institute of Technology and Science Karimnagar
 
PPTX
Introduction to Distributed System
Sunita Sahu
 
PPTX
Network Layer design Issues.pptx
Acad
 
PPTX
Distributed operating system
udaya khanal
 
PPT
Distributed Systems
Rupsee
 
PPTX
Media Access Control
VijayaLakshmi514
 
PPT
Group Communication (Distributed computing)
Sri Prasanna
 
8. mutual exclusion in Distributed Operating Systems
Dr Sandeep Kumar Poonia
 
Message and Stream Oriented Communication
Dilum Bandara
 
Synchronization in distributed computing
SVijaylakshmi
 
Chapter 4 a interprocess communication
AbDul ThaYyal
 
Distributed operating system(os)
Dinesh Modak
 
clock synchronization in Distributed System
Harshita Ved
 
Distributed deadlock
Md. Mahedi Mahfuj
 
Concurrency Control in Distributed Database.
Meghaj Mallick
 
Inter Process Communication
Adeel Rasheed
 
Processor allocation in Distributed Systems
Ritu Ranjan Shrivastwa
 
distributed shared memory
Ashish Kumar
 
Transport layer
reshmadayma
 
Mobile computing (Wireless) Medium Access Control (MAC)
Jyothishmathi Institute of Technology and Science Karimnagar
 
Introduction to Distributed System
Sunita Sahu
 
Network Layer design Issues.pptx
Acad
 
Distributed operating system
udaya khanal
 
Distributed Systems
Rupsee
 
Media Access Control
VijayaLakshmi514
 
Group Communication (Distributed computing)
Sri Prasanna
 

Viewers also liked (19)

PDF
Clock Synchronization in Distributed Systems
Zbigniew Jerzak
 
PDF
6.Distributed Operating Systems
Dr Sandeep Kumar Poonia
 
PDF
Clock Synchronization
innovationwireless
 
DOC
Unit 1 architecture of distributed systems
karan2190
 
PPTX
Clock synchronization using servo-clock
André Costa Lima
 
PPTX
Marketing and concepts of database.
Ashutosh Mishra
 
PPT
Distributed information sys
Meena Chauhan
 
PPT
Virtualization (Distributed computing)
Sri Prasanna
 
PDF
Autonomous Pervasive Systems and the Policy Challenges of a Small World!
Emil Lupu
 
PPT
04 ota053001 clock synchronization theory issue1.0
Vũ Trần Huy
 
PPT
Chapter 10
AbDul ThaYyal
 
PPTX
Communication And Synchronization In Distributed Systems
guest61205606
 
PPTX
Synchronization Pradeep K Sinha
Jawwad Rafiq
 
PPT
Communications is distributed systems
SHATHAN
 
DOCX
Distributed System
Nitesh Saitwal
 
PPT
Pervasive Computing
VijayaLakshmi N
 
PPTX
Wireless Security
Stefano Coratti
 
PDF
Distributed Systems: scalability and high availability
Renato Lucindo
 
PDF
Study: The Future of VR, AR and Self-Driving Cars
LinkedIn
 
Clock Synchronization in Distributed Systems
Zbigniew Jerzak
 
6.Distributed Operating Systems
Dr Sandeep Kumar Poonia
 
Clock Synchronization
innovationwireless
 
Unit 1 architecture of distributed systems
karan2190
 
Clock synchronization using servo-clock
André Costa Lima
 
Marketing and concepts of database.
Ashutosh Mishra
 
Distributed information sys
Meena Chauhan
 
Virtualization (Distributed computing)
Sri Prasanna
 
Autonomous Pervasive Systems and the Policy Challenges of a Small World!
Emil Lupu
 
04 ota053001 clock synchronization theory issue1.0
Vũ Trần Huy
 
Chapter 10
AbDul ThaYyal
 
Communication And Synchronization In Distributed Systems
guest61205606
 
Synchronization Pradeep K Sinha
Jawwad Rafiq
 
Communications is distributed systems
SHATHAN
 
Distributed System
Nitesh Saitwal
 
Pervasive Computing
VijayaLakshmi N
 
Wireless Security
Stefano Coratti
 
Distributed Systems: scalability and high availability
Renato Lucindo
 
Study: The Future of VR, AR and Self-Driving Cars
LinkedIn
 
Ad

Similar to Clock synchronization in distributed system (20)

PPT
Chapter Five Synchonization distributed Sytem.ppt
gadisaAdamu
 
PPT
Chapter Five: Introduction to Syncho.pptduction to Syncho.ppt
gadisaadamu101
 
PPT
dokumen.tips_synchronization-in-distributed-systems-chapter-6.ppt
samaghorab
 
PPT
Time-Synchronization-ds14.pptmmmmmmmmmmmmmmmmmmmmmmmmmmm
mrx19732005
 
PPTX
3. syncro. in distributed system
Gd Goenka University
 
PDF
Clock.pdf
MohdAbdulHaque
 
PPTX
Unit iii-Synchronization
Dhivyaa C.R
 
PPT
Chapter 6-Synchronozation2.ppt
MeymunaMohammed1
 
PPT
Chap 5
suks_87
 
PPTX
Lesson 05 - Time in Distrributed System.pptx
LagamaPasala
 
PPT
Chapter 5-Synchronozation.ppt
sirajmohammed35
 
PPTX
Synchronization of multihop sensor networks in the app layer
Vaishnavi
 
PDF
Clock Synchronization in Distributed Systems
IRJET Journal
 
PPTX
Physical and Logical Clocks
Dilum Bandara
 
PDF
Synchonization in Distributed Systems.pdf
cAnhTrn53
 
PDF
Getting date and time from ntp server with esp8266 node mcu
Elaf A.Saeed
 
PPTX
Unit V Synchronization of distributed system.pptx
OmkarShinde400615
 
Chapter Five Synchonization distributed Sytem.ppt
gadisaAdamu
 
Chapter Five: Introduction to Syncho.pptduction to Syncho.ppt
gadisaadamu101
 
dokumen.tips_synchronization-in-distributed-systems-chapter-6.ppt
samaghorab
 
Time-Synchronization-ds14.pptmmmmmmmmmmmmmmmmmmmmmmmmmmm
mrx19732005
 
3. syncro. in distributed system
Gd Goenka University
 
Clock.pdf
MohdAbdulHaque
 
Unit iii-Synchronization
Dhivyaa C.R
 
Chapter 6-Synchronozation2.ppt
MeymunaMohammed1
 
Chap 5
suks_87
 
Lesson 05 - Time in Distrributed System.pptx
LagamaPasala
 
Chapter 5-Synchronozation.ppt
sirajmohammed35
 
Synchronization of multihop sensor networks in the app layer
Vaishnavi
 
Clock Synchronization in Distributed Systems
IRJET Journal
 
Physical and Logical Clocks
Dilum Bandara
 
Synchonization in Distributed Systems.pdf
cAnhTrn53
 
Getting date and time from ntp server with esp8266 node mcu
Elaf A.Saeed
 
Unit V Synchronization of distributed system.pptx
OmkarShinde400615
 
Ad

More from Sunita Sahu (7)

PPTX
Writing software requirement document
Sunita Sahu
 
PPTX
Writing software requirement document
Sunita Sahu
 
PPTX
RPC: Remote procedure call
Sunita Sahu
 
PPTX
Slowly changing dimension
Sunita Sahu
 
PPTX
Fact less fact Tables & Aggregate Tables
Sunita Sahu
 
PPT
Dimensional Modeling
Sunita Sahu
 
PPT
Attacks in MANET
Sunita Sahu
 
Writing software requirement document
Sunita Sahu
 
Writing software requirement document
Sunita Sahu
 
RPC: Remote procedure call
Sunita Sahu
 
Slowly changing dimension
Sunita Sahu
 
Fact less fact Tables & Aggregate Tables
Sunita Sahu
 
Dimensional Modeling
Sunita Sahu
 
Attacks in MANET
Sunita Sahu
 

Recently uploaded (20)

PDF
International Journal of Information Technology Convergence and services (IJI...
ijitcsjournal4
 
PPTX
Knowledge Representation : Semantic Networks
Amity University, Patna
 
PPTX
Damage of stability of a ship and how its change .pptx
ehamadulhaque
 
DOCX
CS-802 (A) BDH Lab manual IPS Academy Indore
thegodhimself05
 
PPTX
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
PPTX
Thermal runway and thermal stability.pptx
godow93766
 
PDF
MAD Unit - 1 Introduction of Android IT Department
JappanMavani
 
PPTX
Introduction to Design of Machine Elements
PradeepKumarS27
 
PPTX
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
PPTX
Worm gear strength and wear calculation as per standard VB Bhandari Databook.
shahveer210504
 
PDF
Zilliz Cloud Demo for performance and scale
Zilliz
 
PPT
PPT2_Metal formingMECHANICALENGINEEIRNG .ppt
Praveen Kumar
 
PPTX
MATLAB : Introduction , Features , Display Windows, Syntax, Operators, Graph...
Amity University, Patna
 
PDF
PORTFOLIO Golam Kibria Khan — architect with a passion for thoughtful design...
MasumKhan59
 
PPTX
Lecture 1 Shell and Tube Heat exchanger-1.pptx
mailforillegalwork
 
PPT
Electrical Safety Presentation for Basics Learning
AliJaved79382
 
PDF
smart lot access control system with eye
rasabzahra
 
PDF
Biomechanics of Gait: Engineering Solutions for Rehabilitation (www.kiu.ac.ug)
publication11
 
PDF
Design Thinking basics for Engineers.pdf
CMR University
 
PPTX
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
International Journal of Information Technology Convergence and services (IJI...
ijitcsjournal4
 
Knowledge Representation : Semantic Networks
Amity University, Patna
 
Damage of stability of a ship and how its change .pptx
ehamadulhaque
 
CS-802 (A) BDH Lab manual IPS Academy Indore
thegodhimself05
 
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
Thermal runway and thermal stability.pptx
godow93766
 
MAD Unit - 1 Introduction of Android IT Department
JappanMavani
 
Introduction to Design of Machine Elements
PradeepKumarS27
 
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
Worm gear strength and wear calculation as per standard VB Bhandari Databook.
shahveer210504
 
Zilliz Cloud Demo for performance and scale
Zilliz
 
PPT2_Metal formingMECHANICALENGINEEIRNG .ppt
Praveen Kumar
 
MATLAB : Introduction , Features , Display Windows, Syntax, Operators, Graph...
Amity University, Patna
 
PORTFOLIO Golam Kibria Khan — architect with a passion for thoughtful design...
MasumKhan59
 
Lecture 1 Shell and Tube Heat exchanger-1.pptx
mailforillegalwork
 
Electrical Safety Presentation for Basics Learning
AliJaved79382
 
smart lot access control system with eye
rasabzahra
 
Biomechanics of Gait: Engineering Solutions for Rehabilitation (www.kiu.ac.ug)
publication11
 
Design Thinking basics for Engineers.pdf
CMR University
 
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 

Clock synchronization in distributed system

  • 1. 1
  • 2. NEED?? • Time driven systems: in statically scheduled systems activities are started at "precise" times in different points of the distributed system. • Time stamps: certain events or messages are associated with a time stamp showing the actual time when they have been produced; certain decisions in the system are based on the "exact" time of the event or event ordering. • Calculating the duration of activities: if such an activity starts on one processor and finishes on another (e.g. transmitting a message), calculating the duration needs clocks to be synchronized. 2
  • 3.  It is impossible to guarantee that physical clocks run at the same frequency  Lack of global time, can cause problems  Example: UNIX make ◦ Edit output.c at a client ◦ output.o is at a server (compile at server) ◦ Client machine clock can be lagging behind the server machine clock
  • 4. When each machine has its own clock, an event that occurred after another event may nevertheless be assigned an earlier time.
  • 5. • Every computer is equipped with CMOS clock circuit. These are electronic devices that count oscillations occurring in a crystal. • Also called timer, usually a quartz crystal, oscillating at a well defined frequency. • Timer is associated with two registers: A Counter and a Holding Register, counter decreasing one at each oscillations. • When counter reaches zero, an interrupt is generated; this is the clock tick. • Clock tick have a frequency of 60-100 ticks per second. 5
  • 6. • The problems: 1. Crystals cannot be tuned perfectly. Temperature and other external factors can also influence their frequency. Clock drift: the computer clock differs from the real time. 2. Two crystals are never identical. Clock skew: the computer clocks on different processors of the distributed system show different time. 6
  • 7. ☞ Distributed Algorithms • There is no particular time server. • The processors periodically reach an agreement on the clock value by averaging the time of neighbors clock and its local clock. -This can be used if no UTC receiver exists (no external synchronization is needed). Only internal synchronization is performed. - Processes can run on different machines and no global clock to judge which event happens first. 7
  • 8. • Cristian’s Algorithm is centralized algorithm.  The simplest algorithm for setting time, it issues a Remote Procedure Call to time server and obtain the time.  A machine sends a request to time server in “d/2” seconds, where d=max difference between a clock and UTC.  The time server sends a reply with current UTC when receives the request.  The machine measures the time delay between time server sending the message and machine receiving it. Then it uses the measure to adjust the clock. 8
  • 9.  The best estimate of message propagation time= (T0 + T1)/2  The new time can be set to the time returned by server plus time that elapsed since server generated the timestamp: Tnew = Tserver + (T0 + T1)/2 9
  • 10. • It is also a Centralized algorithm and its Time server is an Active Machine.  The server polls each machine periodically, asking it for the time.  When all the results are in, the master computes the average time.  Instead of sending the updated time back to slaves, which would introduce further uncertainty due to network delays, it sends each machine the offset by which its clock needs adjustment.  If master machine fails, any other slave could be elected to take over. 10
  • 11. a) The time daemon sends synchronization query to other machines in group. b) The machines sends timestamps as a response to query. c) The Server averages the three timestamps and tells everyone how to adjust their clock by sending offsets. 11
  • 12. • NTP is an application layer protocol • Default port number 123 • Uses standard UDP Internet transport protocol • Adjust system clock as close to UTC as possible over the Internet. • Enable sufficiently frequently resynchronizations. (scaling well on large num • The NTP service is provided by a network of servers located across the Internet. • Primary servers are connected directly to a time source. (e.g. a radio clock receiving UTC, GPS). bers of clients and servers) 12
  • 13.  Secondary servers are synchronized with primary servers.  The servers are connected in a logical hierarchy called a synchronization subnet. Each level of the synchronization subnet is called stratum. 13
  • 14.  A requests time of B at its own T1  B receives request at its T2, records  B responds at its T3, sending values of T2 and T3  A receives response at its T4  Question: what is θ = TB – TA? Synchronization in Distributed SystemsCS-4513 D-term 2008 14 A B T1 T2 T3 T4
  • 15.  Question: what is θ = TB – TA?  Assume transit time is approximately the same both ways  Assume that B is the time server that A wants to synchronize to Synchronization in Distributed SystemsCS-4513 D-term 2008 15 A B T1 T2 T3 T4
  • 16. ( ) ( )2314 TTTT −−−  A knows (T4 – T1) from its own clock  B reports T3 and T2 in response to NTP request  A computes total transit time of Synchronization in Distributed SystemsCS-4513 D-term 2008 16 A B T1 T2 T3 T4
  • 17. ( ) ( ) 2 2314 TTTT −−− ( ) ( ) 2 2314 3 TTTT T −−− +  One-way transit time is approximately ½ total, i.e.,  B’s clock at T4 reads approximately Synchronization in Distributed SystemsCS-4513 D-term 2008 17 A B T1 T2 T3 T4
  • 18.  Servers organized as strata ◦ Stratum 0 server adjusts itself to WWV directly ◦ Stratum 1 adjusts self to Stratum 0 servers ◦ Etc.  Within a stratum, servers adjust with each other CS-4513 D-term 2008 Synchronization in Distributed Systems 18
  • 20.  Assume no central time source –  Each system maintains its own local clock .  No total ordering of events .  Allow to get global ordering on events.  Assign sequence numbers to messages –  All cooperating processes can agree on order of event. 20
  • 21. • It is used to provide a partial ordering of events with minimal overhead. • It is used to synchronize the logical clock. • It follows some simple rules:  A process increments its counter before each event in that process i.e. Clock must tick once between every two events.  When a process sends a message, it includes its timestamp with the message.  On receiving a message, the receiver process sets its counter to be the maximum of the message counter and increments its own counter . 21
  • 22.  a ‘Happened Before’ b : a→b 1. If a and b are events in the same process, and a comes before b, then a → b. 2. If a :message sent b : receipt of the same message then a → b. 1. Transitive: If a → b and b → c then a → c. 2. Two distinct events a and b are said to be concurrent if a -/->b and b -/->a 22
  • 23. Figure 6-9. (a) Three processes, each with its own clock. The clocks run at different rates.
  • 24.  For two events a and b in same process p1  C(b)= C(a)+1  If a is sending process and b is receiving process of pi and pj then,  Cj(b)=max((Ci(a)+1),Cj(b)) 24