Computer Science Lecture 10, page 1 CS677: Distributed OS Last Class: Naming Name distribution: use...
-
Upload
shauna-mccarthy -
Category
Documents
-
view
215 -
download
1
Transcript of Computer Science Lecture 10, page 1 CS677: Distributed OS Last Class: Naming Name distribution: use...
![Page 1: Computer Science Lecture 10, page 1 CS677: Distributed OS Last Class: Naming Name distribution: use hierarchies DNS X.500 and LDAP.](https://reader036.fdocuments.net/reader036/viewer/2022082711/56649ed35503460f94be3545/html5/thumbnails/1.jpg)
CS677: Distributed OSComputer Science Lecture 10, page 1
Last Class: Naming
• Name distribution: use hierarchies
• DNS
• X.500 and LDAP
![Page 2: Computer Science Lecture 10, page 1 CS677: Distributed OS Last Class: Naming Name distribution: use hierarchies DNS X.500 and LDAP.](https://reader036.fdocuments.net/reader036/viewer/2022082711/56649ed35503460f94be3545/html5/thumbnails/2.jpg)
CS677: Distributed OSComputer Science Lecture 10, page 2
Canonical Problems in Distributed Systems
• Time ordering and clock synchronization• Leader election• Mutual exclusion• Distributed transactions• Deadlock detection
![Page 3: Computer Science Lecture 10, page 1 CS677: Distributed OS Last Class: Naming Name distribution: use hierarchies DNS X.500 and LDAP.](https://reader036.fdocuments.net/reader036/viewer/2022082711/56649ed35503460f94be3545/html5/thumbnails/3.jpg)
CS677: Distributed OSComputer Science Lecture 10, page 3
Clock Synchronization
• Time in unambiguous in centralized systems– System clock keeps time, all entities use this for time
• Distributed systems: each node has own system clock– Crystal-based clocks are less accurate (1 part in million)
– Problem: An event that occurred after another may be assigned an earlier time
![Page 4: Computer Science Lecture 10, page 1 CS677: Distributed OS Last Class: Naming Name distribution: use hierarchies DNS X.500 and LDAP.](https://reader036.fdocuments.net/reader036/viewer/2022082711/56649ed35503460f94be3545/html5/thumbnails/4.jpg)
CS677: Distributed OSComputer Science Lecture 10, page 4
Physical Clocks: A Primer• Accurate clocks are atomic oscillators (one part in 1013)
• Most clocks are less accurate (e.g., mechanical watches)– Computers use crystal-based blocks (one part in million)
– Results in clock drift
• How do you tell time?– Use astronomical metrics (solar day)
• Coordinated universal time (UTC) – international standard based on atomic time– Add leap seconds to be consistent with astronomical time
– UTC broadcast on radio (satellite and earth)
– Receivers accurate to 0.1 – 10 ms
• Need to synchronize machines with a master or with one another
![Page 5: Computer Science Lecture 10, page 1 CS677: Distributed OS Last Class: Naming Name distribution: use hierarchies DNS X.500 and LDAP.](https://reader036.fdocuments.net/reader036/viewer/2022082711/56649ed35503460f94be3545/html5/thumbnails/5.jpg)
CS677: Distributed OSComputer Science Lecture 10, page 5
Clock Synchronization
• Each clock has a maximum drift rate • 1-dC/dt <= 1+
– Two clocks may drift by 2t in time t
– To limit drift to => resynchronize every 2 seconds
![Page 6: Computer Science Lecture 10, page 1 CS677: Distributed OS Last Class: Naming Name distribution: use hierarchies DNS X.500 and LDAP.](https://reader036.fdocuments.net/reader036/viewer/2022082711/56649ed35503460f94be3545/html5/thumbnails/6.jpg)
CS677: Distributed OSComputer Science Lecture 10, page 6
Cristian’s Algorithm
•Synchronize machines to a time server with a UTC receiver
•Machine P requests time from server every seconds
– Receives time t from server, P sets clock to t+treply where treply is the time to send reply to P
– Use (treq+treply)/2 as an estimate of treply
– Improve accuracy by making a series of measurements
![Page 7: Computer Science Lecture 10, page 1 CS677: Distributed OS Last Class: Naming Name distribution: use hierarchies DNS X.500 and LDAP.](https://reader036.fdocuments.net/reader036/viewer/2022082711/56649ed35503460f94be3545/html5/thumbnails/7.jpg)
CS677: Distributed OSComputer Science Lecture 10, page 7
Berkeley Algorithm
• Used in systems without UTC receiver– Keep clocks synchronized with one another
– One computer is master, other are slaves
– Master periodically polls slaves for their times
• Average times and return differences to slaves
• Communication delays compensated as in Cristian’s algo
– Failure of master => election of a new master
![Page 8: Computer Science Lecture 10, page 1 CS677: Distributed OS Last Class: Naming Name distribution: use hierarchies DNS X.500 and LDAP.](https://reader036.fdocuments.net/reader036/viewer/2022082711/56649ed35503460f94be3545/html5/thumbnails/8.jpg)
CS677: Distributed OSComputer Science Lecture 10, page 8
Berkeley Algorithm
a) The time daemon asks all the other machines for their clock values
b) The machines answer
c) The time daemon tells everyone how to adjust their clock
![Page 9: Computer Science Lecture 10, page 1 CS677: Distributed OS Last Class: Naming Name distribution: use hierarchies DNS X.500 and LDAP.](https://reader036.fdocuments.net/reader036/viewer/2022082711/56649ed35503460f94be3545/html5/thumbnails/9.jpg)
CS677: Distributed OSComputer Science Lecture 10, page 9
Distributed Approaches
• Both approaches studied thus far are centralized• Decentralized algorithms: use resync intervals
– Broadcast time at the start of the interval
– Collect all other broadcast that arrive in a period S
– Use average value of all reported times
– Can throw away few highest and lowest values
• Approaches in use today– rdate: synchronizes a machine with a specified machine
– Network Time Protocol (NTP)
• Uses advanced techniques for accuracies of 1-50 ms
![Page 10: Computer Science Lecture 10, page 1 CS677: Distributed OS Last Class: Naming Name distribution: use hierarchies DNS X.500 and LDAP.](https://reader036.fdocuments.net/reader036/viewer/2022082711/56649ed35503460f94be3545/html5/thumbnails/10.jpg)
CS677: Distributed OSComputer Science Lecture 10, page 10
Logical Clocks
• For many problems, internal consistency of clocks is important– Absolute time is less important
– Use logical clocks
• Key idea:– Clock synchronization need not be absolute
– If two machines do not interact, no need to synchronize them
– More importantly, processes need to agree on the order in which events occur rather than the time at which they occurred
![Page 11: Computer Science Lecture 10, page 1 CS677: Distributed OS Last Class: Naming Name distribution: use hierarchies DNS X.500 and LDAP.](https://reader036.fdocuments.net/reader036/viewer/2022082711/56649ed35503460f94be3545/html5/thumbnails/11.jpg)
CS677: Distributed OSComputer Science Lecture 10, page 11
Event Ordering
• Problem: define a total ordering of all events that occur in a system
• Events in a single processor machine are totally ordered• In a distributed system:
– No global clock, local clocks may be unsynchronized
– Can not order events on different machines using local times
• Key idea [Lamport ]– Processes exchange messages
– Message must be sent before received
– Send/receive used to order events (and synchronize clocks)
![Page 12: Computer Science Lecture 10, page 1 CS677: Distributed OS Last Class: Naming Name distribution: use hierarchies DNS X.500 and LDAP.](https://reader036.fdocuments.net/reader036/viewer/2022082711/56649ed35503460f94be3545/html5/thumbnails/12.jpg)
CS677: Distributed OSComputer Science Lecture 10, page 12
Happened Before Relation
• If A and B are events in the same process and A executed before B, then A -> B
• If A represents sending of a message and B is the receipt of this message, then A -> B
• Relation is transitive:– A -> B and B -> C => A -> C
• Relation is undefined across processes that do not exhange messages– Partial ordering on events
![Page 13: Computer Science Lecture 10, page 1 CS677: Distributed OS Last Class: Naming Name distribution: use hierarchies DNS X.500 and LDAP.](https://reader036.fdocuments.net/reader036/viewer/2022082711/56649ed35503460f94be3545/html5/thumbnails/13.jpg)
CS677: Distributed OSComputer Science Lecture 10, page 13
Event Ordering Using HB
• Goal: define the notion of time of an event such that– If A-> B then C(A) < C(B)
– If A and B are concurrent, then C(A) <, = or > C(B)
• Solution: – Each processor maintains a logical clock LCi
– Whenever an event occurs locally at I, LCi = LCi+1
– When i sends message to j, piggyback Lci
– When j receives message from i
• If LCj < LCi then LCj = LCi +1 else do nothing
– Claim: this algorithm meets the above goals
![Page 14: Computer Science Lecture 10, page 1 CS677: Distributed OS Last Class: Naming Name distribution: use hierarchies DNS X.500 and LDAP.](https://reader036.fdocuments.net/reader036/viewer/2022082711/56649ed35503460f94be3545/html5/thumbnails/14.jpg)
CS677: Distributed OSComputer Science Lecture 10, page 14
Lamport’s Logical Clocks
![Page 15: Computer Science Lecture 10, page 1 CS677: Distributed OS Last Class: Naming Name distribution: use hierarchies DNS X.500 and LDAP.](https://reader036.fdocuments.net/reader036/viewer/2022082711/56649ed35503460f94be3545/html5/thumbnails/15.jpg)
CS677: Distributed OSComputer Science Lecture 10, page 15
Example: Totally-Ordered Multicasting
• Updating a replicated database and leaving it in an inconsistent state.