160 likes | 180 Views
Physical clock synchronization. Question 1 . Why is physical clock synchronization important? Question 2 . With atomic clocks becoming affordable, should we care about physical clock synchronization?. Types of Synchronization External Synchronization Internal Synchronization
E N D
Physical clock synchronization Question 1. Why is physical clock synchronization important? Question 2. With atomic clocks becoming affordable, should we care about physical clock synchronization?
Types of Synchronization External Synchronization Internal Synchronization Phase Synchronization Types of clocks Unbounded 0, 1, 2, 3, . . . Bounded 0,1, 2, . . . M-1, 0, 1, . . . Classification Unbounded clocks are not realistic, but are easier to deal with in algorithms. Real clocks are always bounded.
What are these? Drift rate Clock skew Resynchronization interval R Challenges (Drift is unavoidable) Accounting for propagation delay Accounting for processing delay Faulty clocks Terminologies
A simple averaging algorithm Assume n clocks, at most t are faulty Step 1. Read every clock in the system. Step 2. Discard outliers and substitute them by the value of the local clock. Step 3. Update the clock using the average of these values. Synchronization is maintained if n > 3t Why? Internal synchronization Some clocks may be faulty. Exhibits 2-faced behavior
A simple averaging algorithm The maximum difference between the averages computed by two non-faulty nodes is (3td / n) To keep the clocks synchronized, 3td /n < d So,3t < n Internal synchronization
Client pulls data from a time server. For accuracy, clients must compute the round trip time(RTT), and compensate for this delay while adjusting their own clocks. Cristian’s method Time server
Tiered architecture Broadcast mode - least accurate Procedure call - medium accuracy Peer-to-peer mode - upper level servers use this for max accuracy Network Time Protocol (NTP) Time server Level 0 Level 1 Level 1 Level 1 Level 2 Level 2 Level 2 The tree can reconfigure itself if some node fails.
Let Q’s time be ahead of P’s time by . Then T2 = T1 + TPQ + T4 = T3 + TQP - y = TPQ + TQP = T2 +T4 -T1 -T3 (RTT) = (T2 -T4 -T1 +T3) / 2 - (TPQ -TQP) / 2 P2P mode of NTP T2 T3 Q P T1 T4 x Between y/2 and -y/2 So, x- y/2 ≤ ≤ x+ y/2 Ping several times, and obtain the smallest value of y. Use it to calculate
Mutual Exclusion CS p0 CS p1 CS p2 CS p3
Why mutual exclusion? Some appplications are: • Resource sharing • Avoiding concurrent update on shared data • Controlling the grain of atomicity • Medium Access Control in Ethernet • Collision avoidance in wireless broadcasts
Specifications ME1. At most one process in the CS. (Safety property) ME2. No deadlock. (Safety property) ME3. Every process trying to enter its CS must eventually succeed. This is called progress. (Liveness property) Progress is quantified by the criterion of bounded waiting. It measures fairness by answering the question: Between two consecutive CS trips by one process, how many times other processes can enter the CS? There are many solutions, both on the shared memory model and the message-passing model
Message passing solution Client do true send request; reply received enter CS; send release; <other work> od server busy: boolean queue release req Server dorequest received and not busy send reply; busy:= true request received and busy enqueue sender release received and queue is empty busy:= false release received and queue not empty send reply to the head of the queue od reply clients
Comments - Centralized solution is simple. - But the server is a single point of failure. This is BAD. - ME1-ME3 is satisfied, but FIFO fairness is not guaranteed. Why? Can we do better? Yes!
{Life of each process} 1. Broadcast a timestampedrequest to all. 2. Request received enqueue sender in local Q. Not in CS send ack, else postpone sending ack until exit from CS. 3. Enter CS, when (i) You are at the head of your Q (ii) You have received ack from all 4. To exit from the CS, (i) Delete the request from Q, and (ii) Broadcast a timestamped release 5. Release received remove sender from local Q. Decentralized solution 1:Lamport’s algorithm Completely connected topology