SlideShare a Scribd company logo

Distributed Systems
Chapter 5 Synchronization
Synchnonization in Distributed Systems
Time in DS
• Time is an interesting and Important issue in DS
– Ex. At what time of day a particular event occurred at a particular
computer … Consistency (use of timestamp for serialization), e-
commerce, authentication etc.
• Algorithms that depend upon clock synchronization
have been developed for several problems.
• Due to loose synchrony, the notion of physical time is
problematic in DS
– There is no absolute physical “global time” in DS
Clocks
– How time is really measured?
» Earlier: Solar day, solar second, mean solar second
• Solar day: time between two consequtive transits
of the sun
• Solar second: 1/86400 of a solar day
• Mean solar day: average length of a solar day
• Problem: solar day gets longer because of
slowdown of earth rotation due to friction (300
million years ago there were 400 days per year)
Physical Clocks
• International Atomic Time (TAI): number of
ticks of Cesium 133 atom since 1/1/58
(atomic second)
• Atom clock: one second defined as (since
1967) 9,192,631,770 transitions of the atom
Cesium 133
Physical Clocks
• Because of slowdown of earth, leap seconds have
to be introduced
• Correction of TAI is called Universal Coordinated
Time (UTC): 30 leap seconds introduced so far
• Network Time Protocol (NTP) can synchronize
globally with an accuracy of up to 50 msec
Physical Clocks
• TAI seconds are of constant length, unlike solar
seconds. Leap seconds are introduced when necessary
to keep in phase with the sun.
Clocks
– Computers contain physical clock (crystal
oscillator)
» Physical time t, hardware time Hi(t), software time Ci(t)
» The clock output can be read by SW and scaled into a
suitable time unit and the value can be used to timestamp
any event
Ci(t) = Hi(t) + 
– Clock skew
» The instantaneous difference between the
readings of any two clocks
– Clock drift: Crystal-based clocks count time at different
rates, and so diverge.
Why
synchronization?
• You want to catch the 5 pm bus at the Harar stop,
but your watch is off by 15 minutes
– What if your watch is Late by 15 minutes?
– What if your watch is Fast by 15 minutes?
• Synchronization is required for
– Correctness
– Fairness
Why synchronization?
• Airline reservation system
• Server A receives a client request to purchase last
ticket on flight ABC 123.
• Server A timestamps purchase using local clock
9h:15m:32.45s, and logs it. Replies ok to client.
• That was the last seat. Server A sends message to
Server B saying “flight full.”
• B enters “Flight ABC 123 full” + local clock value
(which reads 9h:10m:10.11s) into its log.
• Server C queries A’s and B’s logs. Is confused
that a client purchased a ticket after the flight
became full.
– May execute incorrect or unfair actions.
Clock synchronization
• UTC signals are synchronized and broadcast
regularly from land-based radio stations and
satellites covering many parts of the world
– E.g. in the US the radio station WWV broadcasts time signals on
several short-wave frequencies
– Satellite sources include Geo-stationary Operational
Environmental Satellites (GOES) and the GPS
Clock synchronization
– Radio waves travel at near the speed of light. The propagation
delay can be accounted for if the exact speed and the distance
from the source are known
– Unfortunately, the propagation speed varies with atmospheric
conditions – leading to inaccuracy
– Accuracy of a received signal is a function of both the accuracy
of the source and its distance from the source through the
atmosphere
Clock Synchronization Algorithms
• The relation between clock time and UTC when clocks tick at different
rates.
Problem: show that, in order
to guarantee that no two
clocks differ by more than ,
clocks must be
resynchronized at least every
/2 seconds.
Clock Synchronization Algorithms
• The constant  is specified by the manufacturer and is
known as the maximum drift rate.
• If two clocks are drifting from the Universal Coordinated
Time (UTC) in opposite direction, at a time t after they are
synchronized, they maybe as much as 2*  *t apart.
• If the operating system designer want to guarantee that no
two clocks ever differ by more than , clocks must be
synchronized at least every  /2  seconds.
Clock synchronization
–Remember the definition of
synchronous distributed system?
» Known bounds for message delay, clock
drift rate and execution time.
• Clock synchronization is easy in this
case
» In practice most DS are asynchronous.
• Cristian’s Algorithm
• The Berkeley Algorithm
Clock synchronization in a synchronous system
• Consider internal synch between two procs in a
synch DS
• P sends time t on its local clock to Q in a msg m
• In principle, Q could set its clock to the time t + Ttrans,
where Ttrans is the time taken to transmit m between
them
• The two processes would then agree (internal synch)
Clock synchronization in a synchronous system
• Unfortunately, Ttrans is subject to variation and
is unknown
– All processes are competing for resources with P and Q
and other messages are competing with m for the network
– But there is always a minimum transmission time min that
would be obtained if no other processes executed and no
other network traffic existed
– min can be measured or conservatively estimated
Clock synchronization in a synchronous system
• In synch system, by definition, there is also an upper
bound max on the time taken to transmit any
message
• Let the uncertainty in the msg transmission time be u,
so that u = (max – min)
– If Q sets its clock to be (t + min), then clock skew may be as much
as u (since the message may in fact have taken time max to arrive).
– If Q sets it to (t + max), the skew may again be as large as u.
– If, however, Q sets it clock to (t + (max + min)/2), then the skew is at
most u/2.
– In general, for a synch system, the optimum bound that can be
achieved on clock skew when synchronizing N clocks is u(1-1/N)
• For an asynch system Ttrans = min + x, where x >=0
Cristian’s Algorithm (Accuracy)
• Assumption
– Request & reply via same network
– The value of minimum transmission time min is known or
conservatively estimated.
The Berkeley Algorithm (internal synchronization)
• A coordinator (time server): master
– Periodically the master polls the time of each
client (slave) whose clocks are to be
synchronized.
– Based on the answer (by observing the RTT as in
Cristian’s algorithm), it computes the average
(including its own clock value) and broadcasts the
new time.
• This method is suitable for a system in which no
machine has a WWV receiver getting the UTC.
• The time daemon’s time must be set manually by the
operator periodically.
The Berkeley Algorithm
• The balance of probabilities is that the average
cancels out the individual clock’s tendencies to
run fast or slow
• The accuracy depends upon a nominal maximum
RTT between the master and the slaves
• The master eliminates any occasional readings
associated with larger times than this maximum
The Berkeley Algorithm
– Instead of sending the updated current time
back to the comps – which will introduce further
uncertainty due to message transmission time –
the master send the amount by which each
individual slave’s clock requires adjustment (+
or - )
– The algorithm eliminates readings from faulty
clocks (since these could have significant
adverse effects if an ordinary average was
taken) – a subset of clock is chosen that do not
differ by more than a specified amount and then
the average is taken.
The Berkeley Algorithm
• The time daemon asks all the other machines for their clock values
• The machines answer
• The time daemon tells everyone how to adjust their clock
Averaging Algorithms
• Both Cristian’s and Berkeley’s methods are highly
centralized, with the usual disadvantages - single point
of failure, congestion around the server, … etc.
• One class of decentralized clock synchronization
algorithms works by dividing time into fixed-length re-
synchronization intervals.
• The ith
interval starts at T0 + iR and runs until T0 + (i+1)R,
where T0 is an agreed upon moment in the past, and R
is a system parameter.
25

More Related Content

Similar to Chapter Five: Introduction to Syncho.pptduction to Syncho.ppt (20)

PPT
Clock Synchronization (Distributed computing)
Sri Prasanna
 
PPT
clock synchronization in Distributed System
Harshita Ved
 
PPTX
Unit V Synchronization of distributed system.pptx
OmkarShinde400615
 
PPT
Chapter 10
AbDul ThaYyal
 
PPT
Chapter 6-Synchronozation2.ppt
MeymunaMohammed1
 
PDF
6.Distributed Operating Systems
Dr Sandeep Kumar Poonia
 
PDF
Hu3513551364
IJERA Editor
 
PPT
L12.FA20.ppt
MAliHaider4
 
PPTX
sidra_ayoub[1] .pptx
farantouqeer8
 
PPTX
Lesson 05 - Time in Distrributed System.pptx
LagamaPasala
 
PPTX
Clock synchronization
Medicaps University
 
PDF
TIME SYNCHRONIZATION IN WIRELESS SENSOR NETWORKS: A SURVEY
ijujournal
 
PPTX
slides.06.pptx
balewayalew
 
PPTX
Synchronization in distributed computing
SVijaylakshmi
 
PPTX
Introduction to Timekeeping
Steven Kreuzer
 
PPTX
Synchronization
Ameena Tijjani
 
PPT
CS6601-Unit 4 Distributed Systems
Nandakumar P
 
Clock Synchronization (Distributed computing)
Sri Prasanna
 
clock synchronization in Distributed System
Harshita Ved
 
Unit V Synchronization of distributed system.pptx
OmkarShinde400615
 
Chapter 10
AbDul ThaYyal
 
Chapter 6-Synchronozation2.ppt
MeymunaMohammed1
 
6.Distributed Operating Systems
Dr Sandeep Kumar Poonia
 
Hu3513551364
IJERA Editor
 
L12.FA20.ppt
MAliHaider4
 
sidra_ayoub[1] .pptx
farantouqeer8
 
Lesson 05 - Time in Distrributed System.pptx
LagamaPasala
 
Clock synchronization
Medicaps University
 
TIME SYNCHRONIZATION IN WIRELESS SENSOR NETWORKS: A SURVEY
ijujournal
 
slides.06.pptx
balewayalew
 
Synchronization in distributed computing
SVijaylakshmi
 
Introduction to Timekeeping
Steven Kreuzer
 
Synchronization
Ameena Tijjani
 
CS6601-Unit 4 Distributed Systems
Nandakumar P
 

More from gadisaadamu101 (9)

PPTX
chapter Three artificial intelligence 1.pptx
gadisaadamu101
 
PPTX
Chapter Four Deep Learning artificial intelligence .pptx
gadisaadamu101
 
PPTX
Software Development Life Cycle and Models.pptx
gadisaadamu101
 
PPTX
Introduction to Project Planning chapter 1.pptx
gadisaadamu101
 
PPTX
introduction to software SDLC and Models.pptx
gadisaadamu101
 
PPTX
Introductions to Design Logic.pptx IT level
gadisaadamu101
 
PPT
Network and system administration Chapter 5.pptxChapter 6.ppt
gadisaadamu101
 
PPTX
Network and system administration Chapter 5.pptx
gadisaadamu101
 
PPT
network and system admistration by Chapter 4.ppt
gadisaadamu101
 
chapter Three artificial intelligence 1.pptx
gadisaadamu101
 
Chapter Four Deep Learning artificial intelligence .pptx
gadisaadamu101
 
Software Development Life Cycle and Models.pptx
gadisaadamu101
 
Introduction to Project Planning chapter 1.pptx
gadisaadamu101
 
introduction to software SDLC and Models.pptx
gadisaadamu101
 
Introductions to Design Logic.pptx IT level
gadisaadamu101
 
Network and system administration Chapter 5.pptxChapter 6.ppt
gadisaadamu101
 
Network and system administration Chapter 5.pptx
gadisaadamu101
 
network and system admistration by Chapter 4.ppt
gadisaadamu101
 
Ad

Recently uploaded (20)

PDF
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
PPTX
Hashing Introduction , hash functions and techniques
sailajam21
 
PDF
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
PDF
Biomechanics of Gait: Engineering Solutions for Rehabilitation (www.kiu.ac.ug)
publication11
 
PPTX
原版一样(Acadia毕业证书)加拿大阿卡迪亚大学毕业证办理方法
Taqyea
 
PDF
GTU Civil Engineering All Semester Syllabus.pdf
Vimal Bhojani
 
PPTX
Lecture 1 Shell and Tube Heat exchanger-1.pptx
mailforillegalwork
 
DOC
MRRS Strength and Durability of Concrete
CivilMythili
 
PPTX
Green Building & Energy Conservation ppt
Sagar Sarangi
 
PDF
MAD Unit - 2 Activity and Fragment Management in Android (Diploma IT)
JappanMavani
 
PPTX
Introduction to Design of Machine Elements
PradeepKumarS27
 
PPTX
Day2 B2 Best.pptx
helenjenefa1
 
PPT
Carmon_Remote Sensing GIS by Mahesh kumar
DhananjayM6
 
PDF
AI TECHNIQUES FOR IDENTIFYING ALTERATIONS IN THE HUMAN GUT MICROBIOME IN MULT...
vidyalalltv1
 
PPTX
Damage of stability of a ship and how its change .pptx
ehamadulhaque
 
PDF
Introduction to Productivity and Quality
মোঃ ফুরকান উদ্দিন জুয়েল
 
PDF
Design Thinking basics for Engineers.pdf
CMR University
 
DOCX
CS-802 (A) BDH Lab manual IPS Academy Indore
thegodhimself05
 
PDF
Water Industry Process Automation & Control Monthly July 2025
Water Industry Process Automation & Control
 
PPTX
VITEEE 2026 Exam Details , Important Dates
SonaliSingh127098
 
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
Hashing Introduction , hash functions and techniques
sailajam21
 
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
Biomechanics of Gait: Engineering Solutions for Rehabilitation (www.kiu.ac.ug)
publication11
 
原版一样(Acadia毕业证书)加拿大阿卡迪亚大学毕业证办理方法
Taqyea
 
GTU Civil Engineering All Semester Syllabus.pdf
Vimal Bhojani
 
Lecture 1 Shell and Tube Heat exchanger-1.pptx
mailforillegalwork
 
MRRS Strength and Durability of Concrete
CivilMythili
 
Green Building & Energy Conservation ppt
Sagar Sarangi
 
MAD Unit - 2 Activity and Fragment Management in Android (Diploma IT)
JappanMavani
 
Introduction to Design of Machine Elements
PradeepKumarS27
 
Day2 B2 Best.pptx
helenjenefa1
 
Carmon_Remote Sensing GIS by Mahesh kumar
DhananjayM6
 
AI TECHNIQUES FOR IDENTIFYING ALTERATIONS IN THE HUMAN GUT MICROBIOME IN MULT...
vidyalalltv1
 
Damage of stability of a ship and how its change .pptx
ehamadulhaque
 
Introduction to Productivity and Quality
মোঃ ফুরকান উদ্দিন জুয়েল
 
Design Thinking basics for Engineers.pdf
CMR University
 
CS-802 (A) BDH Lab manual IPS Academy Indore
thegodhimself05
 
Water Industry Process Automation & Control Monthly July 2025
Water Industry Process Automation & Control
 
VITEEE 2026 Exam Details , Important Dates
SonaliSingh127098
 
Ad

Chapter Five: Introduction to Syncho.pptduction to Syncho.ppt

  • 3. Time in DS • Time is an interesting and Important issue in DS – Ex. At what time of day a particular event occurred at a particular computer … Consistency (use of timestamp for serialization), e- commerce, authentication etc. • Algorithms that depend upon clock synchronization have been developed for several problems. • Due to loose synchrony, the notion of physical time is problematic in DS – There is no absolute physical “global time” in DS
  • 4. Clocks – How time is really measured? » Earlier: Solar day, solar second, mean solar second • Solar day: time between two consequtive transits of the sun • Solar second: 1/86400 of a solar day • Mean solar day: average length of a solar day • Problem: solar day gets longer because of slowdown of earth rotation due to friction (300 million years ago there were 400 days per year)
  • 5. Physical Clocks • International Atomic Time (TAI): number of ticks of Cesium 133 atom since 1/1/58 (atomic second) • Atom clock: one second defined as (since 1967) 9,192,631,770 transitions of the atom Cesium 133
  • 6. Physical Clocks • Because of slowdown of earth, leap seconds have to be introduced • Correction of TAI is called Universal Coordinated Time (UTC): 30 leap seconds introduced so far • Network Time Protocol (NTP) can synchronize globally with an accuracy of up to 50 msec
  • 7. Physical Clocks • TAI seconds are of constant length, unlike solar seconds. Leap seconds are introduced when necessary to keep in phase with the sun.
  • 8. Clocks – Computers contain physical clock (crystal oscillator) » Physical time t, hardware time Hi(t), software time Ci(t) » The clock output can be read by SW and scaled into a suitable time unit and the value can be used to timestamp any event Ci(t) = Hi(t) +  – Clock skew » The instantaneous difference between the readings of any two clocks – Clock drift: Crystal-based clocks count time at different rates, and so diverge.
  • 9. Why synchronization? • You want to catch the 5 pm bus at the Harar stop, but your watch is off by 15 minutes – What if your watch is Late by 15 minutes? – What if your watch is Fast by 15 minutes? • Synchronization is required for – Correctness – Fairness
  • 10. Why synchronization? • Airline reservation system • Server A receives a client request to purchase last ticket on flight ABC 123. • Server A timestamps purchase using local clock 9h:15m:32.45s, and logs it. Replies ok to client. • That was the last seat. Server A sends message to Server B saying “flight full.” • B enters “Flight ABC 123 full” + local clock value (which reads 9h:10m:10.11s) into its log. • Server C queries A’s and B’s logs. Is confused that a client purchased a ticket after the flight became full. – May execute incorrect or unfair actions.
  • 11. Clock synchronization • UTC signals are synchronized and broadcast regularly from land-based radio stations and satellites covering many parts of the world – E.g. in the US the radio station WWV broadcasts time signals on several short-wave frequencies – Satellite sources include Geo-stationary Operational Environmental Satellites (GOES) and the GPS
  • 12. Clock synchronization – Radio waves travel at near the speed of light. The propagation delay can be accounted for if the exact speed and the distance from the source are known – Unfortunately, the propagation speed varies with atmospheric conditions – leading to inaccuracy – Accuracy of a received signal is a function of both the accuracy of the source and its distance from the source through the atmosphere
  • 13. Clock Synchronization Algorithms • The relation between clock time and UTC when clocks tick at different rates. Problem: show that, in order to guarantee that no two clocks differ by more than , clocks must be resynchronized at least every /2 seconds.
  • 14. Clock Synchronization Algorithms • The constant  is specified by the manufacturer and is known as the maximum drift rate. • If two clocks are drifting from the Universal Coordinated Time (UTC) in opposite direction, at a time t after they are synchronized, they maybe as much as 2*  *t apart. • If the operating system designer want to guarantee that no two clocks ever differ by more than , clocks must be synchronized at least every  /2  seconds.
  • 15. Clock synchronization –Remember the definition of synchronous distributed system? » Known bounds for message delay, clock drift rate and execution time. • Clock synchronization is easy in this case » In practice most DS are asynchronous. • Cristian’s Algorithm • The Berkeley Algorithm
  • 16. Clock synchronization in a synchronous system • Consider internal synch between two procs in a synch DS • P sends time t on its local clock to Q in a msg m • In principle, Q could set its clock to the time t + Ttrans, where Ttrans is the time taken to transmit m between them • The two processes would then agree (internal synch)
  • 17. Clock synchronization in a synchronous system • Unfortunately, Ttrans is subject to variation and is unknown – All processes are competing for resources with P and Q and other messages are competing with m for the network – But there is always a minimum transmission time min that would be obtained if no other processes executed and no other network traffic existed – min can be measured or conservatively estimated
  • 18. Clock synchronization in a synchronous system • In synch system, by definition, there is also an upper bound max on the time taken to transmit any message • Let the uncertainty in the msg transmission time be u, so that u = (max – min) – If Q sets its clock to be (t + min), then clock skew may be as much as u (since the message may in fact have taken time max to arrive). – If Q sets it to (t + max), the skew may again be as large as u. – If, however, Q sets it clock to (t + (max + min)/2), then the skew is at most u/2. – In general, for a synch system, the optimum bound that can be achieved on clock skew when synchronizing N clocks is u(1-1/N) • For an asynch system Ttrans = min + x, where x >=0
  • 19. Cristian’s Algorithm (Accuracy) • Assumption – Request & reply via same network – The value of minimum transmission time min is known or conservatively estimated.
  • 20. The Berkeley Algorithm (internal synchronization) • A coordinator (time server): master – Periodically the master polls the time of each client (slave) whose clocks are to be synchronized. – Based on the answer (by observing the RTT as in Cristian’s algorithm), it computes the average (including its own clock value) and broadcasts the new time. • This method is suitable for a system in which no machine has a WWV receiver getting the UTC. • The time daemon’s time must be set manually by the operator periodically.
  • 21. The Berkeley Algorithm • The balance of probabilities is that the average cancels out the individual clock’s tendencies to run fast or slow • The accuracy depends upon a nominal maximum RTT between the master and the slaves • The master eliminates any occasional readings associated with larger times than this maximum
  • 22. The Berkeley Algorithm – Instead of sending the updated current time back to the comps – which will introduce further uncertainty due to message transmission time – the master send the amount by which each individual slave’s clock requires adjustment (+ or - ) – The algorithm eliminates readings from faulty clocks (since these could have significant adverse effects if an ordinary average was taken) – a subset of clock is chosen that do not differ by more than a specified amount and then the average is taken.
  • 23. The Berkeley Algorithm • The time daemon asks all the other machines for their clock values • The machines answer • The time daemon tells everyone how to adjust their clock
  • 24. Averaging Algorithms • Both Cristian’s and Berkeley’s methods are highly centralized, with the usual disadvantages - single point of failure, congestion around the server, … etc. • One class of decentralized clock synchronization algorithms works by dividing time into fixed-length re- synchronization intervals. • The ith interval starts at T0 + iR and runs until T0 + (i+1)R, where T0 is an agreed upon moment in the past, and R is a system parameter.
  • 25. 25