1 / 11

Synchronization

Synchronization. CSCI 4780/6780. 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. Logical Clocks.

hoyt-mccray
Télécharger la présentation

Synchronization

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Synchronization CSCI 4780/6780

  2. 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

  3. Logical Clocks • For many applications it is sufficient if all machines agree upon some time • Synchronization with UTC not needed • Logical clocks • Lamport showed that in many cases clock synchronization is not needed • What actually is needed is agreement with regards to ordering of events • Example – Compilation occurred before file editing

  4. Concepts in Logical Clocks • Happens-before relation • a->b if one of the following is true • a and b are events in same process and a occurs before b • If a is an event of sending a message and b is the event of receiving the same message is another process a->b. • Implies that message cannot be received before it is sent • Happens-before is transitive • If a->b and b->c then a->c • If two events in x and y are in two processes that never exchange messages then x & y are concurrent

  5. Lamport’s Logical Clock • Three processes, each with its own clock. The clocks run at different rates.

  6. Lamport’s Algorithm

  7. Placement of Lamport’s Clocks in Dist. Systems

  8. Example: Totally-Ordered Multicasting • Updating a replicated database and leaving it in an inconsistent state.

  9. Problem with Lamport’s Clock What can we infer about: Trcv (m2) < Tsend (m3) Trcv(m1) < Tsend (m2) Lamport’s clock does not capture causality • If a -> b then C(b) > C(a) • But what can you infer by knowing C(e) > C(d)?

  10. Vector Clock • Captures causality • VC(a) < VC (b) implies a causally precedes b • Each process maintains a vector (VCi for Pi) • Size of vector is equal to number of processes in the system • VCi[i] is the number of events that have occurred so far at Pi (VCi[i] is the logical clock at Pi) • VCi[j] = k implies that Pi knows that k events have occurred at Pj (Pi’s knowledge of the local time at Pj)

  11. Maintaining Vector Clock • Vector timestamp algorithm • Three step process • Before executing an event Pi increments VCi[i] • Any message sent from Pi (say, to Pj) will carry the current vector at Pi (VCi) • When Pj receives a message m • Adjusts its own vector (VCj[k] = max (VCj[k], ts(m)[k]) • Executes step 1

More Related