Syllabus | Blank | Homework | ||
Notes | Labs | Scores | Blank |
In a few hundred years, when the history of our time is written from a long-term perspective, it is likely that the most important event those historians will see is not technology, not the Internet, not e-commerce. It is an unprecedented change in human condition. For the first time, they will have to manage themselves. Peter DruckerDistributed OS Theories
![]() |
Physical Clocks
Problem
Sometimes we simply need the exact time, not just an ordering.
Solution
Universal Coordinated Time (UTC):
Problem
Suppose we have a distributed system with a UTC-receiver
somewhere in it => we still have to distribute its time to each machine.
Basic principle
In practice: 1 - r ≤ dC / dt ≤ 1 + r.
Goal
Never let two clocks in any system differ by more than δ time units =>
synchronize at least every δ/(2r) seconds.
Global positioning system
Basic idea
You can get an accurate account of time as a side-effect of GPS.
Problem
Assuming that the clocks of the satellites are accurate and
synchronized:
Principal operation
Observation
4 satellites => 4 equations in 4 unknowns ( with Δr as one of them )
Clock Synchronization Principle
Principle I
Every machine asks a time server for the accurate time at least once
every δ/(2r) seconds (Network Time Protocol).
Note
Okay, but you need an accurate measure of round trip delay, including
interrupt handling and processing incoming messages.
Principle II
Let the time server scan all machines periodically, calculate an
average, and inform each machine how it should adjust its time relative
to its present time.
Note
Okay, you'll probably get every machine in sync. You don't even need
to propagate UTC time.
Fundamental
You'll have to take into account that setting the time back is never
allowed => smooth adjustments.
Problem
We first need to introduce a notion of ordering before we can order anything.
The happened before → relation
![]() |
e11 → e12 , e12 → e22
e21 → e13 , e14 || e24 |
Realization
To realize the relation → we need a clock Ci at each
process Pi in the system, and adjust the clock according
to the following rules.
Condition requirements:
Implementation rules:
→ is irreflixive, defines partial order among events
Totally ordering relation ( => ) can be defined by ( on top of the above )
Example: Totally Ordered Multicasting
n = number of processes in a distributed system
Each event in process Pi ~ vector clock Ci ( integer vector of length n )
Ci = | ![]() |
Ci[1]
Ci[2] .. Ci[n] |
![]() |
Comparing two vector timestamps of events a and b
Equal | ta = tb | iff | all i, | ta[i] = tb[i] | |
Not Equal | ta ≠ tb | iff | some i, | ta[i] ≠ tb[i] | |
Less Than or Equal | ta ≤ tb | iff | all i, | ta[i] ≤ tb[i] | |
Not Less Than or Equal To | ta ![]() |
iff | some i, | ta[i] > tb[i] | |
Less Than | ta < tb | iff | ta ≤ tb and ta ≠ tb ) | ||
Not Less Than | ta ![]() |
iff | !(ta ≤ tb and tb ≠ tb ); | ||
Concurrent | ta || tb | iff | ta ![]() ![]() |
Implementation Rules:
Assertion.
At any instant
Now, a → b iff ta < tb
Example: Updating a replicated database and leaving it in an inconsistent state.
if Send( M1 ) → Send( M2 )
then the receipient should receive M1 before
M2
i.e. Send( M1 ) → Send( M2 ) requires Receive( M1 ) → Receive( M2 )
Birman-Schiper-Stephenson Protocol: Enforcing Causal Ordering of Messages
Assumes broadcast communication channels that do not lose or corrupt messages. ( i.e. everyone talks to everyone ). Use vector clocks to "count" number of messages ( i.e. set d = 1 ). n processes.
Vector Time:
The Protocol:
Example
Schiper-Eggli-Sandoz were able to solve the problem without broadcasting channels
Chandy-Lamport Global State Recording Protocol ( Snapshot Algorithm )
The goal of this distributed algorithm is to capture a consistent global state. It assumes all communication channels are FIFO. It uses a distinguished message called a marker to start the algorithm.
Example
In this example, all processes are connected by communications channels Cij. Messages being sent over the channels are represented by arrows between the processes.
Snapshot s1:
Snapshot s2: now a message is in transit on C12 and C21.
The recorded process states and channel states must be collected and assembled to form the global state. ( e.g. send G.S. to all processes in finite time )
Termination
each process must ensure that
C = { c1, c2, ... ,cn }
ci -- cut event, local state of
site ( or process ) Si at that instant
all Si, all Sj, no ei, no ej such that
i.e. every message received before a cut event
was sent before the cut event
at the sender site in the cut.
Time of a cut
C = { c1, c2, ... ,cn }
Ci -- vector clock of ci
TC = sup ( C1, C2, ... , Cn )
TC[k] = max ( C1[k], C2[k], ... , Cn[k] )
TC = | ![]() |
C1[1] C2[2] . . Cn[n] |
![]() |
-------------- (1) |
TC = sup ( C1, C2, ... , Cn ) = | ![]() |
C1[1] C2[2] . . Cn[n] |
![]() |
On the other hand if (1) is true
we have Ci[i] ≥ Cj[i] for all i, j.
This implies that the the events ci are concurrent
and the cut is consistent.
System Model
Huang's Termination Detection Protocol:
|
![]() |
Example
Total number of messages passed: 8 (one to start each computation, one to return the weight).