Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.

Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.

Like this presentation? Why not share!

- Digital clock by asifnoman240 2079 views
- Telling time by Rachel Hemrick 26602 views
- Logical Clocks (Distributed computing) by Sri Prasanna 16248 views
- Telling the time, tell the time esl... by Irenya S 198967 views
- Digital Clock by JiaahRajpout123 659 views
- Digitalclock project 2016 with time... by Ibrahim R 4299 views

No Downloads

Total views

3,935

On SlideShare

0

From Embeds

0

Number of Embeds

2

Shares

0

Downloads

138

Comments

0

Likes

3

No embeds

No notes for slide

- 1. Logical Clocks Sunetri P. Dasari Summer 2005 CSC8980 Distributed Systems Instructor: Sushil K. Prasad
- 2. What are Logical Clocks ? <ul><li>A logical clock is a mechanism for capturing chronological and causal relationships in a distributed system. </li></ul><ul><li>Clock Implementation </li></ul><ul><ul><li>Data structure </li></ul></ul><ul><ul><li>Clock Update Protocol </li></ul></ul><ul><li>Logical clock algorithms of note are: </li></ul><ul><ul><li>Scalar clocks </li></ul></ul><ul><ul><li>Vector clocks </li></ul></ul><ul><ul><li>Matrix clocks </li></ul></ul>
- 3. Lamport’s Contribution (1/2) <ul><li>Notion of logical time as opposed to absolute time </li></ul><ul><li>Partial ordering of events by occurrence </li></ul><ul><ul><li>Causally Related Events </li></ul></ul><ul><ul><ul><li>If event A happens before event B, then A causally affects B. </li></ul></ul></ul><ul><ul><li>Concurrent Events </li></ul></ul><ul><ul><ul><li>Two distinct events A and B are concurrent if A does not happen before B and B does not happen before A. That is, the events have no causal relationship. </li></ul></ul></ul><ul><li>Extend “Happens Before” relation to provide a consistent total ordering of all events in a distributed system </li></ul><ul><li>Example: make utility – creation times of input.c and input.o </li></ul>
- 4. Lamport’s Contribution (2/2) <ul><li>Lamport introduced a system of logical clocks in order to make the “happens before” relation possible. </li></ul><ul><li>Each process P in the system has its own clock C. </li></ul><ul><li>For every event ‘a’ in the process, C can be looked at as a function that assigns a number C(a), which is the timestamp of the event ‘a’ in process P. </li></ul><ul><li>These numbers are not in any way related to physical time -- that is why they are called logical clocks. </li></ul>
- 5. Happens Before Relation “->” <ul><li>If ‘a’ and ‘b’ are two events in the same process, and ‘a’ occurs before ‘b’, then a -> b is true. </li></ul><ul><li>If ‘a’ is the event of sending a message by one process and ‘b’ is the event of receiving the message by another process, then a -> b is true. </li></ul><ul><li>If a -> b and b -> c, a -> c is true. </li></ul><ul><li>If a (not) -> b and b (not) -> a, then and b are concurrent. </li></ul>
- 6. Logical Clocks (1/2)
- 7. Logical Clocks (2/2) <ul><li>How do we maintain a consistent set of logical clocks, one per process ? </li></ul>
- 8. Three processes, each with its own clock. The clocks run at different rates.
- 9. Lamport's algorithm corrects the clocks.
- 10. Total Ordering with Logical Clocks
- 11. Totally-Ordered Multicasting <ul><li>Updating a replicated database and leaving it in an inconsistent state. </li></ul>
- 12. Totally-Ordered Multicasting
- 13. Scalar Logical Time: Pros and Cons <ul><li>Advantages </li></ul><ul><ul><li>We get a total ordering of events in the system. All the benefits gained from knowing the causality of events in the system apply. </li></ul></ul><ul><ul><li>Small overhead: one integer per process. </li></ul></ul><ul><li>Disadvantage </li></ul><ul><ul><li>Clocks are not strongly consistent: clocks lose track of the timestamp of the event on which they are dependent on. This is because we are using a single integer to store the local and logical time. </li></ul></ul>
- 14. What are Vector Timestamps ? <ul><li>Lamport timestamps do not capture causality </li></ul><ul><li>A vector timestamp VT(a) assigned to an event ‘a’ has the property that if VT(a) < VT(b) for some event ‘b’ , then event ‘a’ is known to causally precede event ‘b’. </li></ul><ul><li>Extend logical timestamps into a list of counters, one per process in the system </li></ul><ul><li>Again, each process keeps its own copy </li></ul>
- 15. What are Vector Timestamps ? <ul><li>Each process P i maintains a vector V i with the following two properties: </li></ul><ul><li>V i [i] = no. of events that have occurred so far at P i </li></ul><ul><li>If V i [j] = k, then P i knows that k events have occurred at P j </li></ul><ul><li>Occurrence of an event at process P i causes an increment in V i [i] (i’th entry in its own vector clock) </li></ul><ul><li>When P i sends a message to P j we have </li></ul><ul><li>V j [k] = max (V j [k], V i [k] ) (element-by-element) </li></ul>
- 16. Illustration of Vector timestamps [1,0,0,0] [2,0,0,0] [0,0,1,0] [2,1,1,0] p 0 p 1 p 2 p 3 [0,0,0,1] [2,2,1,0] [2,1,1,1] [1,0,0,0] [1,0,1,0] [2,0,1,0] [2,2,1,1] [2,2,1,0]
- 17. Vector timestamps accurately represent happens-before relation <ul><li>Define VT(e)<VT(e’) if, </li></ul><ul><ul><li>for all i, VT(e)[i] < VT(e’)[i], and </li></ul></ul><ul><ul><li>for some j, VT(e)[j]<VT(e’)[j] </li></ul></ul><ul><li>Example: if VT(e)=[2,1,1,0] and VT(e’)=[2,3,1,0] then VT(e)<VT(e’) </li></ul><ul><li>Notice that not all VT’s are “comparable” under this rule: consider [4,0,0,0] and [0,0,0,4] </li></ul>
- 18. Vector Timestamps (1/2)
- 19. Vector Timestamps (2/2)
- 20. Vector Clock Consistency <ul><li>The system of vector clocks is strongly consistent </li></ul><ul><li>Every event is assigned a timestamp in such a manner that satisfies the clock consistency condition : </li></ul><ul><li> if e 1 e 2 then vt( e 1 ) < vt( e 2 ) </li></ul><ul><li>If the protocol satisfies the following condition as well, then the clock is said to be strongly consistent: </li></ul><ul><li>if vt( e 1 ) < vt( e 2 ) then e 1 e 2 </li></ul>
- 21. Matrix Time <ul><li>A process P i maintains a matrix </li></ul><ul><li>mt i [1…n, 1…n] where </li></ul><ul><ul><li>mt i [i, i] denotes the logical clock of P i </li></ul></ul><ul><ul><li>mt i [i, j] denotes the latest knowledge that P i has about the local clock, mt J [j, j] of P j (row i is the vector clock of P i ) </li></ul></ul><ul><ul><li>mt i [j, k] represents what P i knows about the latest knowledge that P J has about the local logical clock mt k [k, k] of P k. </li></ul></ul><ul><li>mt i [j, k] = mt J [j, k] </li></ul>
- 22. Matrix Time Protocol <ul><li>At process P i : </li></ul><ul><ul><li>Before executing an event, P i updates its local logical time as follows: </li></ul></ul><ul><li>mt i [i, i] = mt i [i, i] + d (d > 0) </li></ul><ul><ul><li>Each sender process piggybacks a message m with its matrix clock value at sending time. Upon receiving such a message (m, vt) from P j , P i updates its matrix clock as follows: </li></ul></ul><ul><ul><ul><li>for 1 <= k <= n: mt i [i, k] = max(mt i [i, k] , mt[j, k] ) </li></ul></ul></ul><ul><ul><ul><li>for 1 <= k <= n </li></ul></ul></ul><ul><li>for 1 <= q <= n </li></ul><ul><li> mt i [k, q] = max(mt i [k, q] , mt[k, q] ) </li></ul><ul><li>3. mt i [i, i] = mt i [i, i] + d (d > 0) </li></ul>
- 23. Matrix Clock Consistency <ul><li>The system of matrix clocks is strongly consistent </li></ul><ul><li>Every event is assigned a timestamp in such a manner that satisfy the clock consistency condition : </li></ul><ul><li>if e 1 e 2 then mt( e 1 ) < mt( e 2 ) </li></ul><ul><li>If the protocol satisfies the following condition as well, then the clock is said to be strongly consistent: </li></ul><ul><li>if mt( e 1 ) < mt( e 2 ) then e 1 e 2 </li></ul>
- 24. Ordered Message Delivery: Issues <ul><li>Should ordering be done at the message communication layer, or handled by the application ? </li></ul><ul><li>Problems at the communication layer </li></ul><ul><ul><ul><li>Only potential causality is captured as this layer cannot tell what the message contains </li></ul></ul></ul><ul><ul><ul><li>Not all causality may be captured (external communication issues) </li></ul></ul></ul><ul><li>Problems with application-level solutions </li></ul><ul><ul><ul><li>Developer is forced to deal with ordering which may not relate to the core functionality of the app </li></ul></ul></ul>
- 25. End-to-end Argument <ul><li>Saltzer et al., 1984 </li></ul><ul><li>“ A function in question can completely and correctly be implemented only with the knowledge and help of the application standing at the endpoints of the communication system. Therefore, providing that questioned function as a feature of the communication system itself is not possible.” </li></ul><ul><li>Sometimes an incomplete version of the function provided by the communication system may be useful as a performance enhancement. </li></ul>
- 26. References <ul><li>[1] Distributed Systems: Principles and Paradigms </li></ul><ul><li>Andrew S. Tanenbaum, Maarten van Steen </li></ul><ul><li>[2] Leslie Lamport. Time, Clocks and the Ordering of Events in Distributed Systems. </li></ul><ul><li>CACM, Vol. 27, No. 7, July 1978, pp. 558-565 </li></ul><ul><li>[3] M. Raynal, M. Singhal. Logical Time: Capturing Causality in Distributed Systems. </li></ul><ul><li>IEEE Computer, February 1996, pp. 49-56 </li></ul><ul><li>[4] JH Saltzer, DP Reed, and DD Clark. End-to-end arguments in system design. ACM Transactions on Computer Systems, pages 277-288, 1984 </li></ul>

No public clipboards found for this slide

×
### Save the most important slides with Clipping

Clipping is a handy way to collect and organize the most important slides from a presentation. You can keep your great finds in clipboards organized around topics.

Be the first to comment