1.19k likes | 1.2k Views
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 )
E N D
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
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
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
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
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
BSS Protocol Rules • Rule 1Before sending message m, process i increments Ci[i] and timestamps m. Theoretical Foundations > Causal Delivery > Broadcast-based > BSS Protocol
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Theoretical Foundations:Unicast-based Causal Delivery CS/CE/TE 6378 Advanced Operating Systems
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
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
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
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
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
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
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
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
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
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
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