DC M2 Part1
DC M2 Part1
MODULE-2
# Introduction
Usually causality is tracked using physical time. However, in distributed systems, it is not possible to
have global physical time; it is possible to realize only an approximation of it. The knowledge of the causal
precedence relation among the events of processes helps solve a variety of problems in distributed systems.
Examples of some of these problems is as follows:
Distributed algorithms design The knowledge of the causal precedence relation among events helps ensure
liveness and fairness in mutual exclusion algorithms, helps maintain consistency in replicated databases, and
helps design correct deadlock detection algorithms to avoid phantom and undetected deadlocks.
Tracking of dependent events In distributed debugging, the knowledge of the causal dependency among
events helps construct a consistent state for resuming reexecution; in failure recovery, it helps build a
checkpoint; in replicated databases, it aids in the detection of file inconsistencies in case of a network
partitioning.
Knowledge about the progress The knowledge of the causal dependency among events helps measure the
progress of processes in the distributed computation. This is useful in discarding obsolete information,
garbage collection, and termination detection.
Concurrency measure The knowledge of how many events are causally dependent is useful in measuring
the amount of concurrency in a computation. All events that are not causally related can be executed
concurrently. Thus, an analysis of the causality in a computation gives an idea of the concurrency in the
program.
In a system of logical clocks, every process has a logical clock that is advanced using a set of rules. Every
event is assigned a timestamp and the causality relation between events can be generally inferred from their
timestamps. The timestamps assigned to events obey the fundamental monotonicity property; that is, if an event
a causally affects an event b, then the timestamp of a is smaller than the timestamp of b.
# Scalar Time
• Proposed by Lamport in 1978 as an attempt to totally order events in a distributed system.
• Time domain is the set of non-negative integers.
• The logical local clock of a process pi and its local view of the global time are squashed into one
integer variable Ci .
• Rules R1 and R2 to update the clocks are as follows:R1: Before executing an event (send, receive, or
internal), process pi executes the following: Ci := Ci + d (d > 0)
• In general, every time R1 is executed, d can have a different value; however, typically d is kept at 1.
• R2: Each message piggybacks the clock value of its sender at sending time. When a process pi
receives a message with timestamp Cmsg , it executes the following actions:
◮ Ci := max(Ci, Cmsg )
◮ Execute R1.
◮ Deliver the message.
Figure shows evolution of scalar time
# Vector Time
• The system of vector clocks was developed independently by Fidge, Mattern and Schmuck.
• In the system of vector clocks, the time domain is represented by a set of n-dimensional non-negative
integer vectors.
• Each process pi maintains a vector vti [1..n], where vti[i] is the local logical clock of pi and describes
the logical time progress at process pi . vti[j] represents process pi ’s latest knowledge of process pj
local time.
• If vti[j]=x, then process pi knows that local time at process pj has progressed till x.
• The entire vector vti constitutes pi ’s view of the global logical time and is used to timestamp events.
• Process pi uses the following two rules R1 and R2 to update its clock: R1: Before executing an event,
process pi updates its local logical time as follows: vti [i] := vti [i] + d ; (d > 0)
• R2: Each message m is piggybacked with the vector clock vt of the sender process at sending time. On
the receipt of such a message (m,vt), process pi executes the following sequence of actions:
1. Update its global logical time as follows: 1 ≤ k ≤ n : vti[k] := max(vti[k], vt[k])
2. Execute R1.
3. Deliver the message m