SlideShare a Scribd company logo
Synchronization
        Part 1

REK’s adaptation of Claypool’s
        adaptation of
        Tanenbaum’s
    Distributed Systems
          Chapter 5
                                 1
Outline

   Clock Synchronization
   Clock Synchronization Algorithms
   Logical Clocks
   Election Algorithms
   Mutual Exclusion
   Distributed Transactions
   Concurrency Control
              Distributed
              Computing Systems   2
Clock Synchronization
             make example




   When each machine has its own clock, an event
    that occurred after another event may
    nevertheless be assigned an earlier time.

•   Same holds when using NFS mount
•   Can all clocks in a distributed system be synchronized?

                      Distributed
                      Computing Systems            3
Physical Clocks

   It is impossible to guarantee that crystals in different
    computers all run at exactly the same frequency. This
    difference in time values is clock skew.
   “Exact” time was computed by astronomers
       The difference between two transits of the sun is termed a
        solar day. Divide a solar day by 24*60*60 yields a solar
        second.
   However, the earth is slowing! (35 days less in a year
    over 300 million years)
   There are also short-term variations caused by
    turbulence deep in the earth’s core.
       A large number of days (n) were used used to the average
        day length, then dividing by 86,400 to determine the
        mean solar second.
                         Distributed
                         Computing Systems              4
Physical Clocks




Computation of the mean solar day.
           Distributed
           Computing Systems   5
Physical Clocks

   Physicists take over from astronomers and count
    the transitions of cesium 133 atom
      9,192,631,770 cesium transitions == 1 solar

       second
      50 International labs have cesium 133 clocks.

      The Bureau Internationale de l’Heure (BIH)

       averages reported clock ticks to produce the
       International Atomic Time (TAI).
      The TAI is mean number of ticks of cesium 133

       clocks since midnight on January 1, 1958 divided
       by 9,192,631,770 .
                    Distributed
                    Computing Systems       6
Physical Clocks

   To adjust for lengthening of mean solar day,
    leap seconds are used to translate TAI into
    Universal Coordinated Time (UTC).
   UTC is broadcast by NIST from Fort Collins,
    Colorado over shortwave radio station WWV.
    WWV broadcasts a short pulses at the start
    of each UTC second. [accuracy 10 msec.]
   GEOS (Geostationary Environment
    Operational Satellite) also offer UTC service.
    [accuracy 0.5 msec.]
                 Distributed
                 Computing Systems    7
Outline

   Clock Synchronization
   Clock Synchronization Algorithms
   Logical Clocks
   Election Algorithms
   Mutual Exclusion
   Distributed Transactions
   Concurrency Control
              Distributed
              Computing Systems   8
Clock Synchronization Algorithms




   Computer timers go off H times/sec, and increment the count of ticks
    (interrupts) since an agreed upon time in the past.
   This clock value is C.
   Using UTC time, the value of clock on machine p is C p(t).
   For a perfect time, Cp(t) = t and dC/dt = 1.
   For an ideal timer, H =60, should generate 216,000 ticks per hour.
                         Distributed
                         Computing Systems               9
Clock Synchronization
              Algorithms
   But typical errors, 10–5, so the range of ticks per
    second will vary from 215,998 to 216,002.
   Manufacturer specs can give you the maximum drift
    rate (ρ).
   Every ∆t seconds, the worst case drift between two
    clocks will be at most 2ρ∆t.
   To guarantee two clocks never differ by more than
    δ, the clocks must re-synchronize every δ/2ρ
    seconds using one of the various clock
    synchronization algorithms.

                    Distributed
                    Computing Systems       10
Clock Synchronization Algorithms


   Centralized Algorithms
       Cristian’s Algorithm (1989)
       Berkeley Algorithm (1989)
   Decentralized Algorithms
       Averaging Algorithms (e.g. NTP)
       Multiple External Time Sources

                   Distributed
                   Computing Systems   11
Cristian's Algorithm
   Assume one machine (the time server) has
    a WWV receiver and all other machines are
    to stay synchronized with it.
   Every δ/2ρ seconds, each machine
    sends a message to the time server
    asking for the current time.
   Time server responds with message
    containing current time, CUTC.
                Distributed
                Computing Systems   12
Cristian's Algorithm




Getting the current time from a time server
              Distributed
              Computing Systems    13
Cristian's Algorithm

   A major problem – the client clock is
    fast  arriving value of CUTC will be
    smaller than client’s current time, C.
       What to do?
        
            One needs to gradually slow down client
            clock by adding less time per tick.



                     Distributed
                     Computing Systems      14
Cristian’s Algorithm
   Minor problem – the one-way delay from
    the server to client is “significant” and
    may vary considerably.
       What to do?
            Measure this delay and add it to CUTC.
            The best estimate of delay is (T1 – T0)/2.
       In cases when T1 – T0 is above a threshold,
        then ignore the measurement. {outliers}
       Can subtract off I (the server interrupt
        handling time).
       Can use average delay measurement or
        relative latency (shortest recorded delay).
                   Distributed
                   Computing Systems        15
The Berkeley Algorithm




a)   The time daemon asks all the other machines for their clock values.
b)   The machines answer and the time daemon computes the average.
c)   The time daemon tells everyone how to adjust their clock.
                           Distributed
                           Computing Systems                  16
Averaging Algorithms

   Every R seconds, each machine
    broadcasts its current time.
   The local machine collects all other
    broadcast time samples during some
    time interval, S.
   The simple algorithm:: the new local
    time is set as the average of the value
    received from all other machines.

                 Distributed
                 Computing Systems    17
Averaging Algorithms
   A slightly more sophisticated algorithm :: Discard
    the m highest and m lowest to reduce the effect of a
    set of faulty clocks.
   Another improved algorithm :: Correct each
    message by adding to the received time an estimate
    of the propagation time from the ith source.
      extra probe messages are needed to use this

       scheme.
   One of the most widely used algorithms in the
    Internet is the Network Time Protocol (NTP).
      Achieves worldwide accuracy in the range of 1-50

       msec.
                      Distributed
                      Computing Systems      18
Outline

   Clock Synchronization
   Clock Synchronization Algorithms
   Logical Clocks
   Election Algorithms
   Mutual Exclusion
   Distributed Transactions
   Concurrency Control
              Distributed
              Computing Systems   19
Logical Clocks

   For a certain class of algorithms, it is
    the internal consistency of the clocks
    that matters. The convention in these
    algorithms is to speak of logical
    clocks.
   Lamport showed clock synchronization
    need not be absolute. What is
    important is that all processes agree
                 Distributed
    on the order Computing Systems occur.
                  in which events 20
Lamport Timestamps [1978]

     Lamport defined a relation ”happens
      before”. a  b ‘a happens before b’.
     Happens before is observable in two
      situations:
1.    If a and b are events in the same process,
      and a occurs before b, then a  b is true.
2.    If a is the event of a message being sent
      by one process, and b is the event of the
      message being received by another
      process, then a  b is also true.
                 Distributed
                 Computing Systems    21
Lamport Timestamps




                    (impossible)



a)   Each processes with own clock with different rates.
b)   Lamport's algorithm corrects the clocks.
c)   Can add machine ID to break ties
                     Distributed
                     Computing Systems           22
Example: Totally-Ordered Multicasting


  (+$100)                                                     (+1%)




       (San Francisco)                             (New York)

     San Fran customer adds $100, NY bank adds 1% interest
        San Fran will have $1,111 and NY will have $1,110

     Updating a replicated database and leaving it in an
      inconsistent state.
     Can use Lamport’s to totally order
                         Distributed
                         Computing Systems       23
Totally-Ordered Multicast
   A multicast operation by which all
    messages are delivered in the same order
    to each receiver.
   Lamport Details:
       Each message is timestamped with the
        current logical time of its sender.
       Multicast messages are conceptually sent to
        the sender.
       Assume all messages sent by one sender are
        received in the order they were sent and that
        no messages are lost.
                  Distributed
                  Computing Systems        24
Totally-Ordered Multicast
   Lamport Details (cont):
       Receiving process puts a message into a local
        queue ordered according to timestamp.
       The receiver multicasts an ACK to all other
        processes.
       Key Point from Lamport: the timestamp of the
        received message is lower than the timestamp
        of the ACK.
       All processes will eventually have the same
        copy of the local queue  consistent global
        ordering. Distributed
                    Computing Systems       25

More Related Content

What's hot

Distributed operating system
Distributed operating systemDistributed operating system
Distributed operating system
udaya khanal
 
DC_M5_L2_Data Centric Consistency (1).pdf
DC_M5_L2_Data Centric Consistency (1).pdfDC_M5_L2_Data Centric Consistency (1).pdf
DC_M5_L2_Data Centric Consistency (1).pdf
DhruvSingh266810
 
Distributed Deadlock Detection.ppt
Distributed Deadlock Detection.pptDistributed Deadlock Detection.ppt
Distributed Deadlock Detection.ppt
Babar Kamran Ahmed (LION)
 
Agreement Protocols, distributed File Systems, Distributed Shared Memory
Agreement Protocols, distributed File Systems, Distributed Shared MemoryAgreement Protocols, distributed File Systems, Distributed Shared Memory
Agreement Protocols, distributed File Systems, Distributed Shared Memory
SHIKHA GAUTAM
 
CS9222 ADVANCED OPERATING SYSTEMS
CS9222 ADVANCED OPERATING SYSTEMSCS9222 ADVANCED OPERATING SYSTEMS
CS9222 ADVANCED OPERATING SYSTEMS
Kathirvel Ayyaswamy
 
Synchronization in distributed systems
Synchronization in distributed systems Synchronization in distributed systems
Synchronization in distributed systems
SHATHAN
 
Consistency protocols
Consistency protocolsConsistency protocols
Consistency protocols
ZongYing Lyu
 
Chapter 3-Processes.ppt
Chapter 3-Processes.pptChapter 3-Processes.ppt
Chapter 3-Processes.ppt
sirajmohammed35
 
Processes and Processors in Distributed Systems
Processes and Processors in Distributed SystemsProcesses and Processors in Distributed Systems
Processes and Processors in Distributed Systems
Dr Sandeep Kumar Poonia
 
6.Distributed Operating Systems
6.Distributed Operating Systems6.Distributed Operating Systems
6.Distributed Operating Systems
Dr Sandeep Kumar Poonia
 
Naming in Distributed Systems
Naming in Distributed SystemsNaming in Distributed Systems
Naming in Distributed Systems
Nandakumar P
 
Deadlock in Distributed Systems
Deadlock in Distributed SystemsDeadlock in Distributed Systems
Deadlock in Distributed Systems
Pritom Saha Akash
 
fault-tolerance-slide.ppt
fault-tolerance-slide.pptfault-tolerance-slide.ppt
fault-tolerance-slide.ppt
Shailendra61
 
Deadlock in distribute system by saeed siddik
Deadlock in distribute system by saeed siddikDeadlock in distribute system by saeed siddik
Deadlock in distribute system by saeed siddikSaeed Siddik
 
12. dfs
12. dfs12. dfs
Resource management
Resource managementResource management
Resource management
Dr Sandeep Kumar Poonia
 
Distributed system lamport's and vector algorithm
Distributed system lamport's and vector algorithmDistributed system lamport's and vector algorithm
Distributed system lamport's and vector algorithm
pinki soni
 
CS6601 DISTRIBUTED SYSTEMS
CS6601 DISTRIBUTED SYSTEMSCS6601 DISTRIBUTED SYSTEMS
CS6601 DISTRIBUTED SYSTEMS
Kathirvel Ayyaswamy
 

What's hot (20)

Distributed operating system
Distributed operating systemDistributed operating system
Distributed operating system
 
DC_M5_L2_Data Centric Consistency (1).pdf
DC_M5_L2_Data Centric Consistency (1).pdfDC_M5_L2_Data Centric Consistency (1).pdf
DC_M5_L2_Data Centric Consistency (1).pdf
 
Distributed Deadlock Detection.ppt
Distributed Deadlock Detection.pptDistributed Deadlock Detection.ppt
Distributed Deadlock Detection.ppt
 
Agreement Protocols, distributed File Systems, Distributed Shared Memory
Agreement Protocols, distributed File Systems, Distributed Shared MemoryAgreement Protocols, distributed File Systems, Distributed Shared Memory
Agreement Protocols, distributed File Systems, Distributed Shared Memory
 
CS9222 ADVANCED OPERATING SYSTEMS
CS9222 ADVANCED OPERATING SYSTEMSCS9222 ADVANCED OPERATING SYSTEMS
CS9222 ADVANCED OPERATING SYSTEMS
 
Synchronization in distributed systems
Synchronization in distributed systems Synchronization in distributed systems
Synchronization in distributed systems
 
Consistency protocols
Consistency protocolsConsistency protocols
Consistency protocols
 
Chapter 3-Processes.ppt
Chapter 3-Processes.pptChapter 3-Processes.ppt
Chapter 3-Processes.ppt
 
Distributed deadlock
Distributed deadlockDistributed deadlock
Distributed deadlock
 
Processes and Processors in Distributed Systems
Processes and Processors in Distributed SystemsProcesses and Processors in Distributed Systems
Processes and Processors in Distributed Systems
 
6.Distributed Operating Systems
6.Distributed Operating Systems6.Distributed Operating Systems
6.Distributed Operating Systems
 
Naming in Distributed Systems
Naming in Distributed SystemsNaming in Distributed Systems
Naming in Distributed Systems
 
Deadlock in Distributed Systems
Deadlock in Distributed SystemsDeadlock in Distributed Systems
Deadlock in Distributed Systems
 
Chapter 10
Chapter 10Chapter 10
Chapter 10
 
fault-tolerance-slide.ppt
fault-tolerance-slide.pptfault-tolerance-slide.ppt
fault-tolerance-slide.ppt
 
Deadlock in distribute system by saeed siddik
Deadlock in distribute system by saeed siddikDeadlock in distribute system by saeed siddik
Deadlock in distribute system by saeed siddik
 
12. dfs
12. dfs12. dfs
12. dfs
 
Resource management
Resource managementResource management
Resource management
 
Distributed system lamport's and vector algorithm
Distributed system lamport's and vector algorithmDistributed system lamport's and vector algorithm
Distributed system lamport's and vector algorithm
 
CS6601 DISTRIBUTED SYSTEMS
CS6601 DISTRIBUTED SYSTEMSCS6601 DISTRIBUTED SYSTEMS
CS6601 DISTRIBUTED SYSTEMS
 

Similar to Synch

3. syncro. in distributed system
3. syncro. in distributed system3. syncro. in distributed system
3. syncro. in distributed system
Gd Goenka University
 
Clock synchronization in distributed system
Clock synchronization in distributed systemClock synchronization in distributed system
Clock synchronization in distributed system
Sunita Sahu
 
Clock.pdf
Clock.pdfClock.pdf
Clock.pdf
MohdAbdulHaque
 
Shoaib
ShoaibShoaib
Shoaib
ShoaibShoaib
Clock Synchronization (Distributed computing)
Clock Synchronization (Distributed computing)Clock Synchronization (Distributed computing)
Clock Synchronization (Distributed computing)Sri Prasanna
 
Physical and Logical Clocks
Physical and Logical ClocksPhysical and Logical Clocks
Physical and Logical Clocks
Dilum Bandara
 
Synchronization Pradeep K Sinha
Synchronization Pradeep K SinhaSynchronization Pradeep K Sinha
Synchronization Pradeep K Sinha
Jawwad Rafiq
 
Chapter 5-Synchronozation.ppt
Chapter 5-Synchronozation.pptChapter 5-Synchronozation.ppt
Chapter 5-Synchronozation.ppt
sirajmohammed35
 
Lesson 05 - Time in Distrributed System.pptx
Lesson 05 - Time in Distrributed System.pptxLesson 05 - Time in Distrributed System.pptx
Lesson 05 - Time in Distrributed System.pptx
LagamaPasala
 
Unit iii-Synchronization
Unit iii-SynchronizationUnit iii-Synchronization
Unit iii-Synchronization
Dhivyaa C.R
 
slides.06.pptx
slides.06.pptxslides.06.pptx
slides.06.pptx
balewayalew
 
Chapter 6-Synchronozation2.ppt
Chapter 6-Synchronozation2.pptChapter 6-Synchronozation2.ppt
Chapter 6-Synchronozation2.ppt
MeymunaMohammed1
 
Distributed System by Pratik Tambekar
Distributed System by Pratik TambekarDistributed System by Pratik Tambekar
Distributed System by Pratik Tambekar
Pratik Tambekar
 
Timers
TimersTimers
Timer
TimerTimer
Embedded Intro India05
Embedded Intro India05Embedded Intro India05
Embedded Intro India05
Rajesh Gupta
 
Distributed computing time
Distributed computing timeDistributed computing time
Distributed computing time
Deepak John
 

Similar to Synch (20)

3. syncro. in distributed system
3. syncro. in distributed system3. syncro. in distributed system
3. syncro. in distributed system
 
Clock synchronization in distributed system
Clock synchronization in distributed systemClock synchronization in distributed system
Clock synchronization in distributed system
 
Clock.pdf
Clock.pdfClock.pdf
Clock.pdf
 
Shoaib
ShoaibShoaib
Shoaib
 
Shoaib
ShoaibShoaib
Shoaib
 
Clock Synchronization (Distributed computing)
Clock Synchronization (Distributed computing)Clock Synchronization (Distributed computing)
Clock Synchronization (Distributed computing)
 
Physical and Logical Clocks
Physical and Logical ClocksPhysical and Logical Clocks
Physical and Logical Clocks
 
Ds ppt imp.
Ds ppt imp.Ds ppt imp.
Ds ppt imp.
 
Synchronization Pradeep K Sinha
Synchronization Pradeep K SinhaSynchronization Pradeep K Sinha
Synchronization Pradeep K Sinha
 
Chapter 5-Synchronozation.ppt
Chapter 5-Synchronozation.pptChapter 5-Synchronozation.ppt
Chapter 5-Synchronozation.ppt
 
Lesson 05 - Time in Distrributed System.pptx
Lesson 05 - Time in Distrributed System.pptxLesson 05 - Time in Distrributed System.pptx
Lesson 05 - Time in Distrributed System.pptx
 
Unit iii-Synchronization
Unit iii-SynchronizationUnit iii-Synchronization
Unit iii-Synchronization
 
slides.06.pptx
slides.06.pptxslides.06.pptx
slides.06.pptx
 
Chapter 6-Synchronozation2.ppt
Chapter 6-Synchronozation2.pptChapter 6-Synchronozation2.ppt
Chapter 6-Synchronozation2.ppt
 
Distributed System by Pratik Tambekar
Distributed System by Pratik TambekarDistributed System by Pratik Tambekar
Distributed System by Pratik Tambekar
 
Timers
TimersTimers
Timers
 
Timer
TimerTimer
Timer
 
Embedded Intro India05
Embedded Intro India05Embedded Intro India05
Embedded Intro India05
 
Chap 5
Chap 5Chap 5
Chap 5
 
Distributed computing time
Distributed computing timeDistributed computing time
Distributed computing time
 

Synch

  • 1. Synchronization Part 1 REK’s adaptation of Claypool’s adaptation of Tanenbaum’s Distributed Systems Chapter 5 1
  • 2. Outline  Clock Synchronization  Clock Synchronization Algorithms  Logical Clocks  Election Algorithms  Mutual Exclusion  Distributed Transactions  Concurrency Control Distributed Computing Systems 2
  • 3. Clock Synchronization make example  When each machine has its own clock, an event that occurred after another event may nevertheless be assigned an earlier time. • Same holds when using NFS mount • Can all clocks in a distributed system be synchronized? Distributed Computing Systems 3
  • 4. Physical Clocks  It is impossible to guarantee that crystals in different computers all run at exactly the same frequency. This difference in time values is clock skew.  “Exact” time was computed by astronomers  The difference between two transits of the sun is termed a solar day. Divide a solar day by 24*60*60 yields a solar second.  However, the earth is slowing! (35 days less in a year over 300 million years)  There are also short-term variations caused by turbulence deep in the earth’s core.  A large number of days (n) were used used to the average day length, then dividing by 86,400 to determine the mean solar second. Distributed Computing Systems 4
  • 5. Physical Clocks Computation of the mean solar day. Distributed Computing Systems 5
  • 6. Physical Clocks  Physicists take over from astronomers and count the transitions of cesium 133 atom  9,192,631,770 cesium transitions == 1 solar second  50 International labs have cesium 133 clocks.  The Bureau Internationale de l’Heure (BIH) averages reported clock ticks to produce the International Atomic Time (TAI).  The TAI is mean number of ticks of cesium 133 clocks since midnight on January 1, 1958 divided by 9,192,631,770 . Distributed Computing Systems 6
  • 7. Physical Clocks  To adjust for lengthening of mean solar day, leap seconds are used to translate TAI into Universal Coordinated Time (UTC).  UTC is broadcast by NIST from Fort Collins, Colorado over shortwave radio station WWV. WWV broadcasts a short pulses at the start of each UTC second. [accuracy 10 msec.]  GEOS (Geostationary Environment Operational Satellite) also offer UTC service. [accuracy 0.5 msec.] Distributed Computing Systems 7
  • 8. Outline  Clock Synchronization  Clock Synchronization Algorithms  Logical Clocks  Election Algorithms  Mutual Exclusion  Distributed Transactions  Concurrency Control Distributed Computing Systems 8
  • 9. Clock Synchronization Algorithms  Computer timers go off H times/sec, and increment the count of ticks (interrupts) since an agreed upon time in the past.  This clock value is C.  Using UTC time, the value of clock on machine p is C p(t).  For a perfect time, Cp(t) = t and dC/dt = 1.  For an ideal timer, H =60, should generate 216,000 ticks per hour. Distributed Computing Systems 9
  • 10. Clock Synchronization Algorithms  But typical errors, 10–5, so the range of ticks per second will vary from 215,998 to 216,002.  Manufacturer specs can give you the maximum drift rate (ρ).  Every ∆t seconds, the worst case drift between two clocks will be at most 2ρ∆t.  To guarantee two clocks never differ by more than δ, the clocks must re-synchronize every δ/2ρ seconds using one of the various clock synchronization algorithms. Distributed Computing Systems 10
  • 11. Clock Synchronization Algorithms  Centralized Algorithms  Cristian’s Algorithm (1989)  Berkeley Algorithm (1989)  Decentralized Algorithms  Averaging Algorithms (e.g. NTP)  Multiple External Time Sources Distributed Computing Systems 11
  • 12. Cristian's Algorithm  Assume one machine (the time server) has a WWV receiver and all other machines are to stay synchronized with it.  Every δ/2ρ seconds, each machine sends a message to the time server asking for the current time.  Time server responds with message containing current time, CUTC. Distributed Computing Systems 12
  • 13. Cristian's Algorithm Getting the current time from a time server Distributed Computing Systems 13
  • 14. Cristian's Algorithm  A major problem – the client clock is fast  arriving value of CUTC will be smaller than client’s current time, C.  What to do?  One needs to gradually slow down client clock by adding less time per tick. Distributed Computing Systems 14
  • 15. Cristian’s Algorithm  Minor problem – the one-way delay from the server to client is “significant” and may vary considerably.  What to do?  Measure this delay and add it to CUTC.  The best estimate of delay is (T1 – T0)/2.  In cases when T1 – T0 is above a threshold, then ignore the measurement. {outliers}  Can subtract off I (the server interrupt handling time).  Can use average delay measurement or relative latency (shortest recorded delay). Distributed Computing Systems 15
  • 16. The Berkeley Algorithm a) The time daemon asks all the other machines for their clock values. b) The machines answer and the time daemon computes the average. c) The time daemon tells everyone how to adjust their clock. Distributed Computing Systems 16
  • 17. Averaging Algorithms  Every R seconds, each machine broadcasts its current time.  The local machine collects all other broadcast time samples during some time interval, S.  The simple algorithm:: the new local time is set as the average of the value received from all other machines. Distributed Computing Systems 17
  • 18. Averaging Algorithms  A slightly more sophisticated algorithm :: Discard the m highest and m lowest to reduce the effect of a set of faulty clocks.  Another improved algorithm :: Correct each message by adding to the received time an estimate of the propagation time from the ith source.  extra probe messages are needed to use this scheme.  One of the most widely used algorithms in the Internet is the Network Time Protocol (NTP).  Achieves worldwide accuracy in the range of 1-50 msec. Distributed Computing Systems 18
  • 19. Outline  Clock Synchronization  Clock Synchronization Algorithms  Logical Clocks  Election Algorithms  Mutual Exclusion  Distributed Transactions  Concurrency Control Distributed Computing Systems 19
  • 20. Logical Clocks  For a certain class of algorithms, it is the internal consistency of the clocks that matters. The convention in these algorithms is to speak of logical clocks.  Lamport showed clock synchronization need not be absolute. What is important is that all processes agree Distributed on the order Computing Systems occur. in which events 20
  • 21. Lamport Timestamps [1978]  Lamport defined a relation ”happens before”. a  b ‘a happens before b’.  Happens before is observable in two situations: 1. If a and b are events in the same process, and a occurs before b, then a  b is true. 2. If a is the event of a message being sent by one process, and b is the event of the message being received by another process, then a  b is also true. Distributed Computing Systems 21
  • 22. Lamport Timestamps (impossible) a) Each processes with own clock with different rates. b) Lamport's algorithm corrects the clocks. c) Can add machine ID to break ties Distributed Computing Systems 22
  • 23. Example: Totally-Ordered Multicasting (+$100) (+1%) (San Francisco) (New York)  San Fran customer adds $100, NY bank adds 1% interest  San Fran will have $1,111 and NY will have $1,110  Updating a replicated database and leaving it in an inconsistent state.  Can use Lamport’s to totally order Distributed Computing Systems 23
  • 24. Totally-Ordered Multicast  A multicast operation by which all messages are delivered in the same order to each receiver.  Lamport Details:  Each message is timestamped with the current logical time of its sender.  Multicast messages are conceptually sent to the sender.  Assume all messages sent by one sender are received in the order they were sent and that no messages are lost. Distributed Computing Systems 24
  • 25. Totally-Ordered Multicast  Lamport Details (cont):  Receiving process puts a message into a local queue ordered according to timestamp.  The receiver multicasts an ACK to all other processes.  Key Point from Lamport: the timestamp of the received message is lower than the timestamp of the ACK.  All processes will eventually have the same copy of the local queue  consistent global ordering. Distributed Computing Systems 25