lecture 1: logical, physical & casual time (part 2) anish arora cse 763
TRANSCRIPT
![Page 1: Lecture 1: Logical, Physical & Casual Time (Part 2) Anish Arora CSE 763](https://reader035.vdocuments.us/reader035/viewer/2022062511/55176f4c5503460e6e8b4eb6/html5/thumbnails/1.jpg)
Lecture 1: Logical, Physical & Casual Time (Part 2)
Anish Arora
CSE 763
![Page 2: Lecture 1: Logical, Physical & Casual Time (Part 2) Anish Arora CSE 763](https://reader035.vdocuments.us/reader035/viewer/2022062511/55176f4c5503460e6e8b4eb6/html5/thumbnails/2.jpg)
Physical Clocks
• Assume each process i has a physical clock, Ci(t), that is a continuous, differentiable function except where the clock is reset
• Necessary conditions for a system of physical clocks to be correct:
1. Each clock must run at the approximately correct rate
2. The clocks must be synchronized|
![Page 3: Lecture 1: Logical, Physical & Casual Time (Part 2) Anish Arora CSE 763](https://reader035.vdocuments.us/reader035/viewer/2022062511/55176f4c5503460e6e8b4eb6/html5/thumbnails/3.jpg)
Physical Clock Synchronization
![Page 4: Lecture 1: Logical, Physical & Casual Time (Part 2) Anish Arora CSE 763](https://reader035.vdocuments.us/reader035/viewer/2022062511/55176f4c5503460e6e8b4eb6/html5/thumbnails/4.jpg)
Physical Clock Synchronization
• Assume that message transmission time has two components: a minimum delay and an unpredictable delay
Algorithm
• When sending a message, a process timestamps it with the current value of its physical clock
• Upon receiving a message, a process sets its physical clock to the maximum of
1. its current value and
2. the timestamp plus the minimum message delay
![Page 5: Lecture 1: Logical, Physical & Casual Time (Part 2) Anish Arora CSE 763](https://reader035.vdocuments.us/reader035/viewer/2022062511/55176f4c5503460e6e8b4eb6/html5/thumbnails/5.jpg)
Importance of Clock Synchronization
Synchronized clocks are fundamental to the correct functioning of a distributed system
• ordering events (e.g., FCFS scheduling)• consistent updates of replicated data• expiration of privileges• prearranged synchronization• ordering multi-version objects• interpreting data that is a function of
time
![Page 6: Lecture 1: Logical, Physical & Casual Time (Part 2) Anish Arora CSE 763](https://reader035.vdocuments.us/reader035/viewer/2022062511/55176f4c5503460e6e8b4eb6/html5/thumbnails/6.jpg)
The Problem
A distributed system having synchronized clocks should have the following properties:
• At any instant the values of the clocks at any two sites in the distributed should differ by no more than a known quantity
• At any instant the value of a clock at a site should differ from universal time (i. e., “real” time) by at most /2
• The values assumed by any clock should be monotonically increasing
The first property cannot be achieved absolutely, but only with some very high probability
![Page 7: Lecture 1: Logical, Physical & Casual Time (Part 2) Anish Arora CSE 763](https://reader035.vdocuments.us/reader035/viewer/2022062511/55176f4c5503460e6e8b4eb6/html5/thumbnails/7.jpg)
Difficulty of Clock Synchronization
The following factors conspire to prevent perfectly synchronized clocks:
• Clocks cannot be engineered to run at precisely the correct rate
• Sites in a distributed system cannot communicate infinitely often
• There are always unpredictable delays in message delivery
• Faulty or malicious sites may provide incorrect or inconsistent time values to other sites
![Page 8: Lecture 1: Logical, Physical & Casual Time (Part 2) Anish Arora CSE 763](https://reader035.vdocuments.us/reader035/viewer/2022062511/55176f4c5503460e6e8b4eb6/html5/thumbnails/8.jpg)
Standard Time Dissemination
To coordinate time throughout the world, national administrations maintain and disseminate standard time (such as International Atomic Time, TAl, and Coordinated Universal Time, UTC)
U.S. National Institute of Standards and Technology
• WWV, Fort Collins, CO• WWVH, Kauai, HI• WWBV, Boulder, CO• Geosynchronous Orbiting Environmental Satellite
(GOES)• LORAN-C• Global Positioning System (GPS)
![Page 9: Lecture 1: Logical, Physical & Casual Time (Part 2) Anish Arora CSE 763](https://reader035.vdocuments.us/reader035/viewer/2022062511/55176f4c5503460e6e8b4eb6/html5/thumbnails/9.jpg)
Distributed Time Services
There are two widely-used technologies for time service:
OSF DCE's Distributed Time Service• based on Digital’s DECdts
• developed during 1986-90
• a mature commercial product
• described in reference 2
NTP - Network Time Protocol• specified in 1985
• adopted as an Internet Standard Recommended Protocol
• Transarc’s implementation proposed to OSF
![Page 10: Lecture 1: Logical, Physical & Casual Time (Part 2) Anish Arora CSE 763](https://reader035.vdocuments.us/reader035/viewer/2022062511/55176f4c5503460e6e8b4eb6/html5/thumbnails/10.jpg)
DCE Distributed Time Service
A clock is a device that provides a measure of UTC
Real clocks always exhibit some deviation from universal time, or error. The error can never be known exactly, but it can be bounded
So, a clock reports a range of values, anyone of which could be the universal time
![Page 11: Lecture 1: Logical, Physical & Casual Time (Part 2) Anish Arora CSE 763](https://reader035.vdocuments.us/reader035/viewer/2022062511/55176f4c5503460e6e8b4eb6/html5/thumbnails/11.jpg)
DCE DTS Architecture
![Page 12: Lecture 1: Logical, Physical & Casual Time (Part 2) Anish Arora CSE 763](https://reader035.vdocuments.us/reader035/viewer/2022062511/55176f4c5503460e6e8b4eb6/html5/thumbnails/12.jpg)
Obtaining a Time Value from a Server
Unsolicited time information is of minimal value
A request/response protocol gives more information
![Page 13: Lecture 1: Logical, Physical & Casual Time (Part 2) Anish Arora CSE 763](https://reader035.vdocuments.us/reader035/viewer/2022062511/55176f4c5503460e6e8b4eb6/html5/thumbnails/13.jpg)
Obtaining a Time Value from a Server
When a clerk requests a time value from a server it doesn't know exactly when the server read its clock
![Page 14: Lecture 1: Logical, Physical & Casual Time (Part 2) Anish Arora CSE 763](https://reader035.vdocuments.us/reader035/viewer/2022062511/55176f4c5503460e6e8b4eb6/html5/thumbnails/14.jpg)
Obtaining a Time Value from a Server
A interval containing the server's time at the “synchronization instant” can be computed
If lower bounds exist on the times required for intervening activities, the interval can be narrowed
![Page 15: Lecture 1: Logical, Physical & Casual Time (Part 2) Anish Arora CSE 763](https://reader035.vdocuments.us/reader035/viewer/2022062511/55176f4c5503460e6e8b4eb6/html5/thumbnails/15.jpg)
Computing a Correct Time
Time values are obtained from several servers, in case some of them are faulty
If all servers are correct, then the narrowest correct time is simply the intersection of the intervals
![Page 16: Lecture 1: Logical, Physical & Casual Time (Part 2) Anish Arora CSE 763](https://reader035.vdocuments.us/reader035/viewer/2022062511/55176f4c5503460e6e8b4eb6/html5/thumbnails/16.jpg)
Computing a Correct Time
Assume at most one server is faulty
![Page 17: Lecture 1: Logical, Physical & Casual Time (Part 2) Anish Arora CSE 763](https://reader035.vdocuments.us/reader035/viewer/2022062511/55176f4c5503460e6e8b4eb6/html5/thumbnails/17.jpg)
Computing a Correct Time
Assume at most two servers are faulty
![Page 18: Lecture 1: Logical, Physical & Casual Time (Part 2) Anish Arora CSE 763](https://reader035.vdocuments.us/reader035/viewer/2022062511/55176f4c5503460e6e8b4eb6/html5/thumbnails/18.jpg)
Marzullo's Algorithm
1. Arrange the endpoints of the intervals into a list
2. Mark each endpoint as a minimum or maximum
3. Sort the list. (If two endpoints have the same value, the minimums must precede the maximums)
4. Set the initial estimate of the number of faulty servers, f
5. Scan the list in increasing order to find the first endpoint that is in at least M - f intervals, where M is the number of servers
6. Scan the list in decreasing order to find the first endpoint in at least M - f intervals
7. If no such points are found, then there are more than f faulty servers. Increment f and go to step 5
8. The two points found delimit a correct time interval
![Page 19: Lecture 1: Logical, Physical & Casual Time (Part 2) Anish Arora CSE 763](https://reader035.vdocuments.us/reader035/viewer/2022062511/55176f4c5503460e6e8b4eb6/html5/thumbnails/19.jpg)
Adjusting a Clock
Depending on the difference between the local clock and the computed time, one of two methods is used to update the local clock
Abrupt adjustment immediately sets the local clock to the computed time. This is done only if the difference is greater than 10 minutes
Gradual adjustment changes the amount by which the clock is incremented at each tick. It preserves the property that time is a monotonically increasing, continuous function
![Page 20: Lecture 1: Logical, Physical & Casual Time (Part 2) Anish Arora CSE 763](https://reader035.vdocuments.us/reader035/viewer/2022062511/55176f4c5503460e6e8b4eb6/html5/thumbnails/20.jpg)
Adjusting a Clock
For gradual adjustment, a fast clock must be slowed down so that UTC catches up; a slow clock must be speeded up so it catches up to UTC
If the clock is usually incremented by , then during adjustment it is incremented by +
( > 0 clock gains time; < 0 clock loses time)
To achieve the necessary adjustment, the tick increment is adjusted for
ticks
![Page 21: Lecture 1: Logical, Physical & Casual Time (Part 2) Anish Arora CSE 763](https://reader035.vdocuments.us/reader035/viewer/2022062511/55176f4c5503460e6e8b4eb6/html5/thumbnails/21.jpg)
Adjusting a Clock
Example
normal clock increment, =1
additional adjustment, =0.5
clock reading = 100
correct time =102
number of adjustments =(102-100) / 0.5 = 4
![Page 22: Lecture 1: Logical, Physical & Casual Time (Part 2) Anish Arora CSE 763](https://reader035.vdocuments.us/reader035/viewer/2022062511/55176f4c5503460e6e8b4eb6/html5/thumbnails/22.jpg)
Determining the Inaccuracy
Whenever a clock is read, its inaccuracy must be calculated
This inaccuracy has four components:
1. The base inaccuracy at the synchronization point
2. The drift increase
3. The decrease due to the adjustment in the clock
4. The clock resolution
![Page 23: Lecture 1: Logical, Physical & Casual Time (Part 2) Anish Arora CSE 763](https://reader035.vdocuments.us/reader035/viewer/2022062511/55176f4c5503460e6e8b4eb6/html5/thumbnails/23.jpg)
Clerk Synchronization
A clerk synchronizes when its local clock exceeds a specified inaccuracy
1.Obtain time values from a specified number of servers
2.Read the local clock to determine the synchronization instant
3.Translate each server’s time to the synchronization instant
4.Compute best correct time from servers’ time values
5.Compare the local time with best correct time. Report faulty clock or initiate clock adjustment
6.Schedule the next synchronization
![Page 24: Lecture 1: Logical, Physical & Casual Time (Part 2) Anish Arora CSE 763](https://reader035.vdocuments.us/reader035/viewer/2022062511/55176f4c5503460e6e8b4eb6/html5/thumbnails/24.jpg)
Server Synchronization
If the server has a time provider, it periodically synchronizes with its time provider
1.Obtain time value(s) from time provider2.Read the local clock to determine the synchronization instant3.Translate the time provider's time(s) to the synchronization instant4.Compute best correct time from time provider's time(s) and own clock value5.Compare the local time with best correct time. Report faulty clock or initiate clock adjustment6.Schedule the next synchronization
![Page 25: Lecture 1: Logical, Physical & Casual Time (Part 2) Anish Arora CSE 763](https://reader035.vdocuments.us/reader035/viewer/2022062511/55176f4c5503460e6e8b4eb6/html5/thumbnails/25.jpg)
Server Synchronization
If a server has no local time provider, it periodically synchronizes with other servers.
1. Obtain time values from all local servers
2. Read the local clock to determine the synchronization instant
3. Translate the server’s times to the synchronization instant
4. Compute best correct time from time server’s times and own clock value
5. Compare the local time with best correct time. Report faulty clock or initiate clock adjustment
6. Schedule the next synchronization