1 / 26

Synchronization

Synchronization. Clock Synchronization In a centralized system time is unambiguous. In a distributed system agreement on time is not obvious . When each machine has its own clock, an event that occurred after another event may be assigned an earlier time. Physical clocks.

ilario
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

  2. Clock SynchronizationIn a centralized system time is unambiguous.In a distributed system agreement on time is not obvious. • When each machine has its own clock, an event that occurred after another event maybe assigned an earlier time.

  3. Physical clocks • Computer Clock ≡ Timer • Oscillating crystal (under tension) • 2 register: counter and holding register • Interrupt ( clock tick) when counter gets to zero • Nclocks n rates (clock skew) • UTC (Universal Coordinated Time) is the current universal time • standard • Radio pulse to synchronize (±10 msec) • Satellite (± 0.5 msec)

  4. Clock Synchronization Algorithms If 1 – r < dC/dt < 1 + rrmaximum drift rate If 2 clock drift from UTC in the opposite directions, after Δt, ε = 2r Dt Resynchronization interval d/2r dmaximum time difference • The relation between clock time and UTC when clocks tick at different rates.

  5. Cristian's Algorithmsynchronization with a time serverPeriodically (T < d/2r s) synchronizationrequest to time server • Time must never runbackward gradual changes • Non zero message propagation time (estimate value = (T1-T0-I) /2 )

  6. The Berkeley Algorithmsynchronization without time server • The time daemon asks all the other machines for their clock value discrepancies • The machines answer • The time daemon tells everyone how to adjust their clock to the average • no Universal Coordinated Time available

  7. Centralized algorithms have disadvantages. • Decentralized algorithms can use averaging methods. • NTP (Network Time Protocol) provides an accuracy of 1-50 msec using advanced algorithms. • For many purposes it is sufficient that all machines agree on the same time. • Logical clocks • Often processes need to agree on the order in which events occur.

  8. Lamport Timestamps happens before If a b C(a) < C(b) If a snd., b rcv. C(a) < C(b) C(a)  C(b) If C(b) < C(a) C(b) = C(a)+1 We obtain a total ordering of all events in the system but Lamport timestamps don’t capture causality Vector timestamps each process Pi has a vector Vi so that: Vi[i] is the number of events occurred so far at Pi If Vi[j]=k Pi knows k events occurred at Pj

  9. Global StateIt is the local state of each process, together with the messages currently in transit in a distributed systemA distributed snapshot reflects a consistent global state

  10. Global State Knowledge of the state in which a distributed system currently is, is useful Any process P may initiate the algorithm recording its local state. P • Organization of a process and channels for a distributed snapshot • A process P sends a marker along each of its outgoing channels

  11. Global State • Process Q receives a marker for the first time, records its local state and send a marker along each outgoing channel • Q records all incoming message • Q receives a marker for its incoming channel and finishes recording the state of the incoming channel • A process has finished its part of the algorithm when it has received a marker • along each of its incoming channels, and processed each one. Then its state is collected • Many snapshots may be in progress at the same time.

  12. Election AlgorithmsThe Bully Algorithm (1/2) Selecting a coordinator • The bully election algorithm • Process 4 holds an election • Process 5 and 6 respond, telling 4 to stop • Now 5 and 6 each hold an election

  13. The Bully Algorithm (2/2) • Process 6 tells 5 to stop • Process 6 wins and tells everyone

  14. A Ring Algorithm Each process knows who its successor is. • Election algorithm using a ring (without token).

  15. Mutual Exclusion:critical regions in distributed systemsA Centralized Algorithm(to simulate a single processor system, needs a coordinator) • Process 1 asks the coordinator for permission to enter a critical region. Permission is granted • Process 2 then asks permission to enter the same critical region. The coordinator does not reply. • When process 1 exits the critical region, it tells the coordinator, which then replies to 2

  16. A Distributed Algorithmrequires a total ordering of all events in the systemA message contains the critical region name, the process number and the current time • Two processes (0,2) want to enter the same critical region at the same moment. • Process 0 has the lowest timestamp, so it wins and enters the critical region. • When process 0 is done, it sends an OK also, so 2 can now enter the critical region. • This algorithm is worse than the centralized one (n points of failure, scaling, multiple messages…)

  17. A Token Ring Algorithmwhen the process acquires the token, it accesses the critical region (if needed) start • An unordered group of processes on a network. • A logical, ordered, ring constructed in software. Each process knows who • is the next in line

  18. Mutual Exclusion • A comparison of three mutual exclusion algorithms. *With dependence on the mechanism

  19. The Transaction ModelA transaction permits that a whole set of related instructionswould be successfully completed or none would be completed.Special primitives are requested ( supplied by system or language) • Examples of primitives for transactions.

  20. The Transaction Model • Transactions are ACID: • Atomic : to outside, they happen indivisibly • Consistent : they don’t violate system invariants • Isolated : concurrent transactions don’t interfere • Durable : the changes are permanent • These flat transactions have some limitations... • No partial result is permitted • In a large system they can take a lot of time

  21. Nested and Distributed Transactions • A nested transaction: it follows a logical (hierarchical) division of the work • A distributed transaction: it is logically flat and operates on distributed data

  22. How to implement transactions?Private Workspace • Copying everything in a private workspace is prohibitive… • Example: dealing with a file system: • The file index and disk blocks for a three-block file • The situation after a transaction has modified block 0 and appended block 3 • After committing

  23. Write-ahead Log rollback • Files are actually modified in place, but a record is written to log all the changes • a) A transaction • b) – d) The log before each statement is executed • In distributed systems each machine keeps its own log of changes to its local file system

  24. Concurrency Control allows several transaction to be executed simultaneously, leaving data in a consistent way. Transactions access data in a specific order • General (layered) organization of managers for handling transactions.

  25. Concurrency Control • General organization of managers for handling distributed transactions.

  26. Serializability (d) • a) – c) Three transactions T1, T2, and T3 • Legal serialized result : x= 1,2,3 depending upon which one runs last • d) Possible schedules • Synchronization can be achieved or with mutex or with explicit timestamp and following pessimistic or optimistic approach.

More Related