1 / 39

CS 425 / ECE 428

CS 425 / ECE 428.  2013, I. Gupta, K. Nahrtstedt, S. Mitra, N. Vaidya, M. T. Harandi, J. Hou. A Distributed System (DS) consists of a number of processes. Each process has a state (values of variables). State of a may change as a result of a computation step or communication step

jlorraine
Download Presentation

CS 425 / ECE 428

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. CS 425 / ECE 428  2013, I. Gupta, K. Nahrtstedt,S. Mitra,N. Vaidya, M. T. Harandi, J. Hou

  2. A Distributed System (DS) consists of a number of processes. Each process has a state (values of variables). State of a may change as a result of a computation step or communication step Processes may communicate by message-passing or via shared memory Message-passing: Send & Receive message Shared memory: Write & Read shared memory Basics

  3. An event is an abstraction to represent steps performed by a process Each process has a local clock, which may drift Synchronous systems: Each action is performed within bounded amount of time (e.g., a computation step, message delivery over the network, memory operation) Asynchronous systems: Unbounded delay may be incurred. The processes may perform computation at arbitrarily different “rates”. Messages may be delayed for unbounded intervals. Basics

  4. Compute event Send event Receive event Event types in message-passing systems

  5. Real time at which events occur can be used to determine the order of the events Can we infer event ordering in absence of real-time? Is real-time sufficientto infer causal dependency between events? Is it possible for event a to have affected event b ? Ordering of Events

  6. “happened-before” relation defined without using real-time Notation: a  b a happened-before b Three rules for message-passing systems: Events on the same process: Events a and b occur at the SAME process, and a occurs before b, then a  b If a = Send(m) event and b = Receive(m) events then a  b Transitivity: if a  b and b  c then a  c Happened-Before Relation

  7. Events Occurring at Three Processes a  b Why?

  8. Events Occurring at Three Processes a  b Why? b  c Why?

  9. Events Occurring at Three Processes a  b Why? b  c Why? a  f Why?

  10. Events Occurring at Three Processes a  b Why? b  c Why? a  f Why? a  e ????

  11. If a  b and b  a then a and b are (logically) concurrent events Notation: a || b Concurrent events are not causally related Happened-Before

  12. Identify concurrent events

  13. Need some mechanism to track the ordering of events in the program without using real-time Logical timestamps useful for this Lamport introduced the logical clock mechanism Ordering of events

  14. Each process Pi maintains a logical clock Li Intialialize Li = 0 at the start of the process We will describe how timestamps are updated for each type of event separately Logical Clock (Lamport Clock)

  15. Compute event at process Pi: Increment Li by 1 New value of Li is the timestamp of the compute event Logical Clock (Lamport Clock)

  16. LamportTimestamps Each event is assigned a scalar timestamps

  17. Compute event at process Pi: Increment Li by 1 New value of Li is the timestamp of the compute event Send event at process Pi: Consider e = send(m) Increment Li by 1 New value of Li is the timestamp of send event e Piggyback the timestamp of e with message m Logical Clock (Lamport Clock)

  18. LamportTimestamps Each event is assigned a scalar timestamps

  19. Compute event at process Pi: Increment Li by 1 New value of Li is the timestamp of the compute event Send event at process Pi: Consider e = send(m) Increment Li by 1 New value of Li is the timestamp of send event e Piggyback the timestamp of e with message m Receive event at process Pi: Suppose (m,t) where m is a message, and t is the piggybacked timestamp, is received at event e at Pi Update Li as Li := max(Li, t)+1 Logical Clock (Lamport Clock)

  20. Lamport Timestamps

  21. Find the Mistake Physical Time 1 2 p 1 4 0 3 1 4 3 p 2 0 2 2 3 6 p 3 4 0 8 6 3 5 4 7 p 4 0 5 6 7 Clock Value n timestamp Message

  22. Corrected Example: Lamport Logical Time Physical Time 1 2 p 1 8 0 7 1 8 3 p 2 0 2 2 3 6 p 3 4 0 10 9 3 5 4 7 p 4 0 5 6 7 Clock Value n timestamp Message

  23. L(a) denotes Lamport or Logical timestamp of event a If a  b then L(a) < L(b) However, L(b) > L(a) does not imply that a  b Properties of Lamport Clock

  24. Properties of Lamport Clock Physical Time 1 2 p 1 8 0 7 1 8 3 p 2 0 2 2 3 6 p 3 4 0 10 9 3 5 4 7 p 4 0 5 6 7 Clock Value n IDENTIFY CONCURRENTEVENTS timestamp Message

  25. Vector Logical Clocks With Lamport Logical Timestamp e  f  timestamp(e) < timestamp (f), but timestamp(e) < timestamp (f)  {e  f} OR {e and f concurrent} Vector Logical time addresses this issue:

  26. Vector Logical Clocks With Lamport Logical Timestamp e  f  timestamp(e) < timestamp (f), but timestamp(e) < timestamp (f)  {e  f} OR {e and f concurrent} Vector Logical time addresses this issue: Each process maintains a vector clock,length = number of processes

  27. Vector Logical Clocks With Lamport Logical Timestamp e  f  timestamp(e) < timestamp (f), but timestamp(e) < timestamp (f)  {e  f} OR {e and f concurrent} Vector Logical time addresses this issue: Each process maintains a vector clock Vi,length = number of processes At each event, process i increments ith element of vector Vi  The new Vi is the timestamp of the event

  28. Vector Timestamps Vector clocks initialized to all-0 vector at each process Initial value: (0,0,0)

  29. Vector Logical Clocks With Lamport Logical Timestamp e  f  timestamp(e) < timestamp (f), but timestamp(e) < timestamp (f)  {e  f} OR {e and f concurrent} Vector Logical time addresses this issue: Each process maintains a vector clock,length = number of processes At each event, process i increments ith element of vector Vi  The new Vi is the timestamp of the event A message carries the Send event’s vector timestamp

  30. Vector Logical Clocks With Lamport Logical Timestamp e  f  timestamp(e) < timestamp (f), but timestamp(e) < timestamp (f)  {e  f} OR {e and f concurrent} Vector Logical time addresses this issue: Each process maintains a vector clock,length = number of processes At each event, process i increments ith element of vector Vi  The new Vi is the timestamp of the event A message carries the Send event’s vector timestamp For a receive(message) event at process k … letVmessage denote vector timestamp received with the message Max(Vk[j] , Vmessage[j]), if j is not k Vk[j] + 1 j = k Vk[j] =

  31. Vector Timestamps Piggybacked timestamp for message m1 (2,0,0) (2,2,0)

  32. Example: Vector Timestamps 1,0,0,0 2,0,0,0 4,0,2,2 3,0,2,2 (1,0,0,0) (4,0,2,2) 1,2,0,0 1,1,0,0 (2,0,0,0) (1,2,0,0) (2,0,2,2) 2,0,2,0 4,2,5,3 4,2,4,2 2,0,1,0 2,2,3,0 (2,0,2,0) (2,0,2,3) 2,0,2,2 2,0,2,3 2,0,2,1 Physical Time p 1 0,0,0,0 p 2 0,0,0,0 p 3 0,0,0,0 p 4 0,0,0,0 Vector logical clock n,m,p,q (vector timestamp) Message

  33. Comparing Vector Timestamps VT1 = VT2, iff VT1[i] = VT2[i], for all i = 1, … , n VT1 < VT2, iff VT1[i] < VT2[i], for all i = 1, … , n VT1 < VT2, iff VT1 < VT2 &  j (1 < j < n & VT1[j] < VT2 [j]) Then: VT1 is concurrent with VT2 iff (not VT1 < VT2 AND not VT2 < VT1)

  34. The vector clock length equals number of processes. Can shorter vectors suffice? In general, for vector clocks, the number of elements must equal the number of processes.

  35. Causality If a happened before b, then b “potentially causally depends” on b Potential causality

  36. Summary Physical and Logical clocks Lamport (Logical) & vector timestamps Happened-before relation Causality

More Related