180 likes | 268 Views
This class covers the concepts of events ordering in distributed systems, synchronization of logical and physical clocks, bound on clock drifting, "happened before" partial ordering, space-time diagrams, clock conditions, implementation rules, total ordering of events, scheduling issues, algorithms, and physical clocks. Key concepts include logical clocks, clock conditions, ordering events totally, total ordering in mutex problem, algorithm rules for resource requesting and releasing, anomalous behavior, and physical clocks' implementation rules.
E N D
CS533 Concepts of Operating SystemsClass 8 Time, Clocks, and the Ordering of Events in a Distributed System By Constantia Tryman
What will be covered • Concept of events ordering in distributed system • Synchronization of logical clocks to order events totally • Specialized synchronization using physical clocks • Bound on how far synchrony clocks can drift apart CS533 - Concepts of Operating Systems
Partial Ordering • : “happened before” • Definition: • If a and b are events from Pi, a comes before b then a b (same process) • If a is sending message m by Pi and b is receiving m by Pj then a b (b/t 2 processes) • If a b and b c, then a c (1 or more processes) • “space-time” diagram • Horizontal: space • Vertical: time • Wavy lines: message CS533 - Concepts of Operating Systems
Space-time Diagram CS533 - Concepts of Operating Systems
Logical Clocks • Clock: a way of assigning number to an event • Logical Clock: order in which events occur • Ci<a> : define clock Ci to process Pi for event a • System of clock represented by: C<b> = Cj<b> CS533 - Concepts of Operating Systems
Space-Time diagram CS533 - Concepts of Operating Systems
Clock Condition • Clock Condition (CC): For events a,b: if a b then C<a> C<b> • Converse condition will not hold => concurrent events happen at the same time • CC is satisfied by: • C1: if a & b are events by Pi, a comes before b, then Ci<a> Ci<b> • C2: if a sends message m by Pi, b is a receipt of m by Pj, then Ci<a> Cj<b> CS533 - Concepts of Operating Systems
Implementation Rule • To guarantee that system of clocks satisfies CC • IR1: Each process Pi increments Ci between any two successive events (tick is occurring between P’s events) • IR2: (each message contains Tm = time msg sent) • A. if a is sending message m by Pi then m contains timestamp Tm = Ci<a> • B. upon receiving m, Pj sets Cj its present value and Tm • IR1 and 2 imply that CC is satisfied CS533 - Concepts of Operating Systems
Ordering Events Totally • Define : • If event a in Pi and b in Pj then a b if either • Ci<a> Cj<b> or • Ci<a> = Cj<b> and Pi < Pj • a b means Ci<a> Cj<b> • extends CS533 - Concepts of Operating Systems
Total Ordering of Events • Algorithm for solving mutex problem: • Process which granted the resource must release before granting resource to another Process • Different requirements for resource must be granted in order they’re made • Every Process granted with resource will eventually release it so every request is eventually granted • Issue: doesn’t tell which Process granted if request resource concurrently with another Process CS533 - Concepts of Operating Systems
Scheduling Issue • Cannot be solved by Central Scheduling Process • Ex: P1 requests P0, P1 sends message P2, P2 requests P0 If P2 is granted first, violate II (granted in the order they make) CS533 - Concepts of Operating Systems
Algorithm Rules • Resource Request by Pi • Pi sends message, M: “Tm: Pi request resource” to every Processes • Pi puts message M to its request Queue • When Message Received by Pj • Pj places M on request Queue • Sends acknowledgement message to Pi • Releasing Resource • Pi removes any M from request Queue • Pi sends message, M3: “Tm3: Pi releases resource” to every Processes CS533 - Concepts of Operating Systems
Algorithm Rules Cont. • When Pj received Pi release resource • Removes any M: “Tm: Pi requests resource” from request Queue • Pi is granted the resource • M in request Queue ordered before any other requests defined by • Pi has received M2 from every other process time stamped Tm2 (where Tm2 Tm) CS533 - Concepts of Operating Systems
Anomalous Behavior • Resource scheduling algorithm ordered request by total ordering will result in Anomalous Behavior • Strong Clock Condition: event a,b in : if a b then C<a> C<b> • : events in all systems • uses physical clocks to eliminate anomalous behavior CS533 - Concepts of Operating Systems
Physical Clocks • Ci(t): reading of clock Ci at physical time t • dCi(t)/dt = rate of clock is running 1 • PC1: a constant K << 1 such that i: | dCi(t)/dt - 1| < k, where k 10-6 • PC2: i,j: |Ci(t) – Cj(t)| < CS533 - Concepts of Operating Systems
Physical Clocks Cont. • a b Cj<a> = t, Cj<b> = t + • shortest transmission time for interprocess messages • i,j,t Cj (t+ ) – Ci (t) > 0 • By PC1 Ci (t+ ) – Ci (t) > (1 - k) • By PC2 Ci (t+ ) – Cj (t) > 0 if / (1-k) CS533 - Concepts of Operating Systems
Implementation Rules • IR1’: i if Pi doesn’t receive a message at physical time t then Ci is differentiable at t and dCi(t)/dt 0 • IR2’ • If Pi sends message M at physical time t, then M contains Tm = Ci(t) • Upon receiving M at time t’ Pj sets Cj(t’) = max ( Cj(t’ – 0), Tm + m ) CS533 - Concepts of Operating Systems
Theorem Theorem: Assume strongly connected graph of Processes with diameter d obeying IR1’ and IR2’ Assume m, m for constant and t t0 • PC1 holds • constant and such that every seconds a message sent over every arch (m ) PC2 is satisfied by: d (2k + ) t ≳ t0 + d Assumption: + ≪ CS533 - Concepts of Operating Systems