1 / 119

Theoretical Foundations

Theoretical Foundations. Clocks Logical clocks ( Lamport ) Partially ordered clocks ( Fidge ) Causally ordered message delivery Broadcast-based ( Birman et al.) Unicast-based ( Raynal , Schiper & Toueg ) System states Global snapshots ( Chandy & Lamport )

bobbiej
Download Presentation

Theoretical Foundations

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. Theoretical Foundations • Clocks • Logical clocks (Lamport) • Partially ordered clocks (Fidge) • Causally ordered message delivery • Broadcast-based (Birman et al.) • Unicast-based (Raynal, Schiper & Toueg) • System states • Global snapshots (Chandy & Lamport) • Termination detection (Huang) Theoretical Foundations

  2. Basics of Message Delivery • sendp(m) • Transmission of message m by process p to a set of destinations denoted destinations(m) • receiveq(m) • Reception of message m by process q • sendp(m)  receiveq(m) • deliverq(m) • Delivery of message m to process q • receiveq(m)  deliverq(m) Theoretical Foundations > Causal Delivery

  3. Causal Delivery • Causal Delivery: • If sendi(w)  sendj(m), and q∈destinations(w) and q∈destinations(m), then deliverq(w)  deliverq(m) • What’s an example of a causal delivery protocol? • Transmission Control Protocol (TCP) Theoretical Foundations > Causal Delivery

  4. Broadcast-based Causal Delivery • Broadcast: • when a process sends a message, it sends the message to every process in the system • Called a multicast when sending to a defined group Theoretical Foundations > Causal Delivery > Broadcast-based

  5. BSS Protocol • Broadcast-based causal delivery protocol • Assumes an external service implements group abstraction • sendp(m) broadcasts message m to the entire group in a single action • Assumes a lossless network • Any message broadcast will eventually be received unless the sender or destination fail • Assumes a failure detection mechanism exists • Will remove failed processes from the group • Will flush broadcasts at the time of a failure Theoretical Foundations > Causal Delivery > Broadcast-based > BSS Protocol

  6. BSS Protocol Rules • Rule 1Before sending message m, process i increments Ci[i] and timestamps m. Theoretical Foundations > Causal Delivery > Broadcast-based > BSS Protocol

  7. BSS Protocol Rules • Rule 2On reception of message m sent by process i and timestampedtm, process j (≠ i) delays delivery of m until: ∀k:[1…n] tm[k] = Cj[k] + 1; if k = i tm[k] ≤ Cj[k]; if k ≠ i Theoretical Foundations > Causal Delivery > Broadcast-based > BSS Protocol

  8. BSS Protocol Rules • Rule 3When a message m is delivered, Cj is updated to max(Cj, tm). Theoretical Foundations > Causal Delivery > Broadcast-based > BSS Protocol

  9. BSS Safety and Liveness • Safety: • messages are always delivered in causal order • Causal delivery is never violated • Liveness: • a message will never be indefinitely delayed • Every message will be delivered eventually Theoretical Foundations > Causal Delivery > Broadcast-based > BSS Protocol

  10. BSS Protocol Exercise • Rule 1: i increments Ci[i] and timestamps m [0 0 0] P [0 0 0] Q [0 0 0] R Theoretical Foundations > Causal Delivery > Broadcast-based > BSS Protocol

  11. BSS Protocol Exercise • Rule 1: i increments Ci[i] and timestamps m [1 0 0] P [1 0 0] [0 0 0] Q [0 0 0] R Theoretical Foundations > Causal Delivery > Broadcast-based > BSS Protocol

  12. BSS Protocol Exercise [1 0 0] P [1 0 0] [0 0 0] Q [0 0 0] R Theoretical Foundations > Causal Delivery > Broadcast-based > BSS Protocol

  13. BSS Protocol Exercise • Rule 1: i increments Ci[i] and timestamps m [1 0 0] P [1 0 0] [0 0 0] Q [0 0 1] [0 0 1] R Theoretical Foundations > Causal Delivery > Broadcast-based > BSS Protocol

  14. BSS Protocol Exercise • Rule 2: Delivery the message [1 0 0] P [1 0 0] [0 0 0] Q [0 0 1] [0 0 1] R Theoretical Foundations > Causal Delivery > Broadcast-based > BSS Protocol

  15. BSS Protocol Exercise • Rule 3: Cj is updated to max(Cj, tm) [1 0 0] P [1 0 0] [1 0 0] Q [0 0 1] [0 0 1] R Theoretical Foundations > Causal Delivery > Broadcast-based > BSS Protocol

  16. BSS Protocol Exercise • Rule 2: Delivery the message [1 0 0] P [1 0 0] [1 0 0] Q [0 0 1] [0 0 1] R Theoretical Foundations > Causal Delivery > Broadcast-based > BSS Protocol

  17. BSS Protocol Exercise • Rule 3: Cj is updated to max(Cj, tm) [1 0 1] P [1 0 0] [1 0 0] Q [0 0 1] [0 0 1] R Theoretical Foundations > Causal Delivery > Broadcast-based > BSS Protocol

  18. BSS Protocol Exercise • Rule 2: Delivery the message [1 0 1] P [1 0 0] [1 0 0] Q [0 0 1] [0 0 1] R Theoretical Foundations > Causal Delivery > Broadcast-based > BSS Protocol

  19. BSS Protocol Exercise • Rule 3: Cj is updated to max(Cj, tm) [1 0 1] P [1 0 0] [1 0 1] Q [0 0 1] [0 0 1] R Theoretical Foundations > Causal Delivery > Broadcast-based > BSS Protocol

  20. BSS Protocol Exercise [1 0 1] P [1 0 0] [1 0 1] Q [0 0 1] [0 0 1] R Theoretical Foundations > Causal Delivery > Broadcast-based > BSS Protocol

  21. BSS Protocol Exercise • Rule 1: i increments Ci[i] and timestamps m [1 0 1] P [1 0 0] [1 1 1] [1 1 1] Q [1 1 1] [0 0 1] [0 0 1] R Theoretical Foundations > Causal Delivery > Broadcast-based > BSS Protocol

  22. BSS Protocol Exercise • Rule 2: Delivery the message [1 0 1] P [1 0 0] [1 1 1] [1 1 1] Q [1 1 1] [0 0 1] [0 0 1] R Theoretical Foundations > Causal Delivery > Broadcast-based > BSS Protocol

  23. BSS Protocol Exercise • Rule 3: Cj is updated to max(Cj, tm) [1 1 1] P [1 0 0] [1 1 1] [1 1 1] Q [1 1 1] [0 0 1] [0 0 1] R Theoretical Foundations > Causal Delivery > Broadcast-based > BSS Protocol

  24. BSS Protocol Exercise • Rule 2: Delay delivering the message [1 1 1] P [1 0 0] [1 1 1] [1 1 1] Q [1 1 1] [0 0 1] [0 0 1] R Theoretical Foundations > Causal Delivery > Broadcast-based > BSS Protocol

  25. BSS Protocol Exercise • Rule 2: Deliver the message [1 1 1] P [1 0 0] [1 1 1] [1 1 1] Q [1 1 1] [0 0 1] [0 0 1] R Theoretical Foundations > Causal Delivery > Broadcast-based > BSS Protocol

  26. BSS Protocol Exercise • Rule 3: Cj is updated to max(Cj, tm) [1 1 1] P [1 0 0] [1 1 1] [1 1 1] Q [1 1 1] [0 0 1] [1 0 1] R Theoretical Foundations > Causal Delivery > Broadcast-based > BSS Protocol

  27. BSS Protocol Exercise • Rule 2: Check the buffer for delayed messages [1 1 1] P [1 0 0] [1 1 1] [1 1 1] Q [1 1 1] [0 0 1] [1 0 1] R Theoretical Foundations > Causal Delivery > Broadcast-based > BSS Protocol

  28. BSS Protocol Exercise • Rule 2: Deliver the message [1 1 1] P [1 0 0] [1 1 1] [1 1 1] Q [1 1 1] [0 0 1] [1 0 1] R Theoretical Foundations > Causal Delivery > Broadcast-based > BSS Protocol

  29. BSS Protocol Exercise • Rule 3: Cj is updated to max(Cj, tm) [1 1 1] P [1 0 0] [1 1 1] [1 1 1] Q [1 1 1] [0 0 1] [1 1 1] R Theoretical Foundations > Causal Delivery > Broadcast-based > BSS Protocol

  30. Proof of BSS Safety • Safety: • messages are always delivered in causal order • Causal delivery is never violated • Must prove • If send(m1)  send(m2) then deliveri(m1)  deliveri(m2) • Two cases: • Same process: sendp(m1)  sendp(m2) • Different processes: sendp(m1)  sendq(m2) Theoretical Foundations > Causal Delivery > Broadcast-based > BSS Protocol

  31. Proof of BSS Safety: Case 1 • If sendp(m1)  sendp(m2) then deliveri(m1)  deliveri(m2) [2 1 0] P [1 0 0] [2 0 0] [1 1 0] [2 1 0] Q [1 1 0] [2 1 0] R Theoretical Foundations > Causal Delivery > Broadcast-based > BSS Protocol

  32. Proof of BSS Safety: Case 2 • If sendp(m1)  sendq(m2) then deliveri(m1)  deliveri(m2) R1 R1 [1 1 0] X [1 1 0] update(R1) [0 1 0] create(R1) R1 [1 1 0] Y create(R1) R1 [0 1 0] [1 1 0] Z R1 R1 Theoretical Foundations > Causal Delivery > Broadcast-based > BSS Protocol

  33. Quiz Question • Assume sentQ(m)  sentQ(n), process P ∈dests(m), and P ∈dests(n).If deliverP(n)  deliverP(m), then safety is violated. • True Theoretical Foundations > Causal Delivery > Broadcast-based > BSS Protocol

  34. Proof of BSS Liveness • Liveness: • a message will never be indefinitely delayed • Every message will be delivered eventually • Must prove • If sendi(m) and receivej(m) then deliverj(m) • Two counterexamples: • If k = i then tm[k] will never equal Cj[k] + 1 • If k ≠ i then tm[k] will always be greater than Cj[k] Theoretical Foundations > Causal Delivery > Broadcast-based > BSS Protocol

  35. Proof of BSS Liveness: Counterexample 1 • If k = i then tm[k] will never equal Cj[k] + 1 • tm[k] is not less than Cj[k] + 1 • Process isent message m • Hence, Cj[i] < Ci[i] when m was timestamped • If tm[k] is more than Cj[k] + 1 • Process i sent other messages prior to m • BSS assumes a lossless network • Process j will eventually receive the other messages from i • Hence, tm[k] will eventually equal Cj[k] + 1 • Proves if sendi(m) and receivej(m) then deliverj(m) Theoretical Foundations > Causal Delivery > Broadcast-based > BSS Protocol

  36. Proof of BSS Liveness: Counterexample 2 • If k ≠ i then tm[k] will always be greater than Cj[k] • tm[k] is greater than Cj[k] • Before sending message m to process j, process i received messages from process k that process j has not received • BSS is broadcast-based • Process k also sent these messages to process j • BSS assumes a lossless network • Process j will eventually receive the messages from k • Hence, tm[k] will eventually be less than or equal to Cj[k] • Proves if sendi(m) and receivej(m) then deliverj(m) Theoretical Foundations > Causal Delivery > Broadcast-based > BSS Protocol

  37. Quiz Question • Assume sentQ(m)  sentQ(n), process P ∈dests(m), and P ∈dests(n).If deliverP(m) never occurs, then liveness is violated. • True Theoretical Foundations > Causal Delivery > Broadcast-based > BSS Protocol

  38. Theoretical Foundations • Clocks • Logical clocks (Lamport) • Partially ordered clocks (Fidge) • Causally ordered message delivery • Broadcast-based (Birman et al.) • Unicast-based (Raynal, Schiper & Toueg) • System states • Global snapshots (Chandy & Lamport) • Termination detection (Huang) Theoretical Foundations

  39. Theoretical Foundations:Unicast-based Causal Delivery CS/CE/TE 6378 Advanced Operating Systems

  40. Unicast-based Causal Delivery • Unicast: • when a process sends a message, it sends the message to one process in the system Theoretical Foundations > Causal Delivery > Unicast-based

  41. RST Protocol • RST: • Raynal, Schiper& Toueg • A causal delivery protocol • Uses matrices to track messages sent • Assumes a lossless network • Any message unicast will eventually be received unless the sender or destination fail Theoretical Foundations > Causal Delivery > Unicast-based > RST Protocol

  42. RST Protocol Variables • Every process manages two variables • DELIVj[i] • An array [1…n] that represents the number of messages sent from process i and delivered to process j • SENTj[k, l] • A matrix [n x n] that represents the number of messages sent from process k to process l (not necessarily delivered) from process j’s perspective • Both are initialized with 0s Theoretical Foundations > Causal Delivery > Unicast-based > RST Protocol

  43. RST Protocol Rules • Rule 1After sending message m to process j with a copy of SENTi (called tm), process i increments SENTi[i, j]. Theoretical Foundations > Causal Delivery > Unicast-based > RST Protocol

  44. RST Protocol Example • Rule 1: Timestamp message with current SENT [0 0 0] P 0 0 00 0 00 0 0 [0 0 0] Q 0 0 00 0 00 0 0 0 0 00 0 00 0 0 [0 0 0] R 0 0 00 0 00 0 0 Theoretical Foundations > Causal Delivery > Unicast-based > RST Protocol

  45. RST Protocol Example • Rule 1: Increment SENTi[i, j] [0 0 0] P 0 0 00 0 00 0 0 [0 0 0] Q 0 0 00 0 10 0 0 0 0 00 0 00 0 0 [0 0 0] R 0 0 00 0 00 0 0 Theoretical Foundations > Causal Delivery > Unicast-based > RST Protocol

  46. RST Protocol Example • Rule 1: Timestamp message with current SENT [0 0 0] P 0 0 00 0 00 0 0 0 0 00 0 10 0 0 [0 0 0] Q 0 0 00 0 10 0 0 0 0 00 0 00 0 0 [0 0 0] R 0 0 00 0 00 0 0 Theoretical Foundations > Causal Delivery > Unicast-based > RST Protocol

  47. RST Protocol Example • Rule 1: Increment SENTi[i, j] [0 0 0] P 0 0 00 0 00 0 0 0 0 00 0 10 0 0 [0 0 0] Q 0 0 01 0 10 0 0 0 0 00 0 00 0 0 [0 0 0] R 0 0 00 0 00 0 0 Theoretical Foundations > Causal Delivery > Unicast-based > RST Protocol

  48. RST Protocol Rules • Rule 2On reception of message m from process i and piggybacked with tm, process j delays delivery of m until: ∀k:[1…n] tm[k, j] ≤ DELIVj[k] Theoretical Foundations > Causal Delivery > Unicast-based > RST Protocol

  49. RST Protocol Example • Rule 2: j = 0; k = 0; tm[k, j] ≤ DELIVj[k]? Yes, 0 ≤ 0 [0 0 0] P 0 0 00 0 00 0 0 0 0 00 0 10 0 0 [0 0 0] Q 0 0 01 0 10 0 0 0 0 00 0 00 0 0 [0 0 0] R 0 0 00 0 00 0 0 Theoretical Foundations > Causal Delivery > Unicast-based > RST Protocol

  50. RST Protocol Example • Rule 2: j = 0; k = 1; tm[k, j] ≤ DELIVj[k]? Yes, 0 ≤ 0 [0 0 0] P 0 0 00 0 00 0 0 0 0 00 0 10 0 0 [0 0 0] Q 0 0 01 0 10 0 0 0 0 00 0 00 0 0 [0 0 0] R 0 0 00 0 00 0 0 Theoretical Foundations > Causal Delivery > Unicast-based > RST Protocol

More Related