0% found this document useful (0 votes)
2 views

DC Module 2 .Pptx

The document outlines key concepts in distributed computing, including logical time, leader election algorithms, global state recording, and termination detection. It discusses various algorithms such as the Bully and Ring algorithms for leader election, and the Chandy-Lamport algorithm for snapshot recording. Additionally, it addresses the challenges of recording global states and detecting termination in distributed systems.

Uploaded by

testaccnnt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

DC Module 2 .Pptx

The document outlines key concepts in distributed computing, including logical time, leader election algorithms, global state recording, and termination detection. It discusses various algorithms such as the Bully and Ring algorithms for leader election, and the Chandy-Lamport algorithm for snapshot recording. Additionally, it addresses the challenges of recording global states and detecting termination in distributed systems.

Uploaded by

testaccnnt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 76

CST402 DISTRIBUTED COMPUTING

-MODULE 2

PREPARED BY SHARIKA T R, AP, SNGCE 1


Syllabus- Election algorithm, Global state and Termination detection

•Logical time – A framework for a system of logical clocks, Scalar time, Vector
time.
•Leader election algorithm – Bully algorithm, Ring algorithm.Global state and
snapshot recording algorithms – System model and definitions, Snapshot algorithm
for FIFO channels – Chandy Lamport algorithm.
•Termination detection – System model of a distributed computation, Termination
detection using distributed snapshots, Termination detection by weight throwing,
Spanning-tree-based algorithm.
PREPARED BY SHARIKA T R, AP, SNGCE 8
Logical Time - Introduction
Logical Time - Introduction
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 -liveness and fairness in mutual exclusion algorithms, helps
maintain consistency in replicated databases, and helps design correct deadlock detection
algorithms to avoid undetected deadlocks.
● Tracking of dependent events -In distributed debugging, the knowledge of the causal
dependency among events helps construct a consistent state for resuming re-execution; 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.
A framework for a system of logical clocks

PREPRED BY SHARIKA T R, AP, SNGCE 12


A framework for a system of logical clocks

13
It dictates what information about the logical time is piggybacked in a message
and how this information is used by the receiving process to update its view of
the a global time.
20
Scalar time basic Properties

PREPARED BY SHARIKA T R, AP, SNGCE 21


Basic properties of Vector Time

30
PREPARED BY SHARIKA T R, AP, SNGCE 31
Leader election algorithm

•Leader election requires that all the processes agree on a common


distinguished process, also termed as the leader.
•A leader is required in many distributed systems because algorithms are
typically not completely symmetrical, and some process has to take the
lead in initiating the algorithm;

•Another reason is that we would not want all the processes to replicate
the algorithm a initiation, to save on resources.
PREPARED BY SHARIKA T R, AP, SNGCE 33
• An algorithm for choosing a unique process to play a particular role
(coordinator) is called an election algorithm.
• An election algorithm is needed for this choice.
• It is essential that all the processes agree on the choice.
• Afterwards, if the process that plays the role of server wishes to retire
then another election is required to choose a replacement.
• We say that a process calls the election if it takes an action that
initiates a particular run of the election algorithm.
• At any point in time, a process Pi is either a participant – meaning that
it is engaged in some run of the election algorithm – or a
34

non-participant – meaning that it is not currently engaged in any


election.
Two Leader election algorithms,

❏ A ring-based election algorithm


❏ Bully algorithm

PREPARED BY SHARIKA T R, AP, SNGCE 35


Ring-based Election algorithm
• Each process Pi has a communication channel to the next process in the
ring, p ( i + 1) mod N ,all messages are sent clockwise around the ring.
• The goal of this algorithm is to elect a single process called the
coordinator, Initially, every process is marked as a non-participant in an
election.
• Any process can begin an election. It proceeds by marking itself as a
participant, placing its identifier in an election message and sending it to its
clockwise neighbour.
• When a process receives an election message, it compares the identifier in
the message with its own. PREPARED BY SHARIKA T R, AP, SNGCE 36

• If the arrived identifier is greater, then it forwards the message to its


neighbour.
• If the arrived identifier is smaller and the receiver is not a
participant, then it substitutes its own identifier in the message and
forwards it; but it does not forward the message if it is already a
participant.
• On forwarding an election message in any case, the process marks
itself as a participant.
• If, however, the received identifier is that of the receiver itself, then
this process’s identifier must be the greatest, and it becomes the
coordinator.
• The coordinator marks itself as a non-participant once more and
sends an elected message to its neighbour, announcing its election
37

and enclosing its identity


Ring algorithm – Example
In a ring topology 7 processes are connected with different ID’s as shown:
P20->P5->P10->P18->P3->P16->P9 If process P10 initiates election, after how many
message passes will the coordinator be elected and known to all the processes. What
modification will take place to the election message as it passes through all the
processes?Calculate total number of election messages and coordinator messages

PREPARED BY SHARIKA T R, AP, SNGCE 45


20 20
P20
18 Elec
) ted
0 msg
g s(2 (20
) P5
dm
cte
Ele
P9

Elec
20

ted
)
msg(20

m
20

sg (
20)
Elected
18
P10

)
20
g(
P16

dms
cte
Ele 10

Ele
cte
dm
sg
(20
0)
) sg (2 P18 20
ed m
Elect
20
P3
18 18
46

20

Election messages =12


Elected messages =7 (on completion of election)
The Bully algorithm

39
43
The Bully algorithm – Example

Pid’s 4,2,1,5,6,3,7. P7 was the initial coordinator and crashed,


Illustrate Bully algorithm, if P4 initiates election. Calculate total
number of election messages and coordinator messages .
Global state and snapshot recording algorithms- Introduction
▪ Recording the global state of a distributed system on-the-fly is an important
paradigm when one is interested in analysing, testing, or verifying properties
associated with distributed execution
▪ Unfortunately, the lack of both a globally shared memory and a global clock in a
distributed system, added to the fact that message transfer delays in these systems
are finite but unpredictable, makes this problem non-trivial.
▪ A distributed computing system consists of spatially separated processes that do not
share a common memory and communicate asynchronously with each other by
message passing over communication channels
▪ Each component of a distributed system has a local state.
▪ The state of a process is characterized by the state of its local memory and a history
of its activity.
▪ The state of a channel is characterized by the set of messages sent along the channel
Global state and snapshot recording algorithms- Introduction

▪ The global state of a distributed system is a collection of the local states of its
components
▪ Recording the global state of a distributed system is an important paradigm and it
finds applications in several aspects of distributed system design
▪ For examples, in detection of stable properties such as deadlocks, and termination
, global state of the system is examined for certain properties;
▪ for failure recovery, a global state of the distributed system (called a checkpoint)
is periodically saved and recovery from a processor failure is done by restoring
the system to the last saved global state
▪ If shared memory were available, an up-to-date state of the entire system would
be available to the processes sharing the memory.
▪ The absence of shared memory necessitates ways of getting a coherent and
complete view of the system based on the local states of individual processes.
Interpretation in terms of cuts

Cut C1 is inconsistent because message m1 is flowing from the FUTURE to the


PAST
Issues in Recording a global state

• If a global physical clock were available, the following simple


procedure could be used to record a consistent global snapshot of a
distributed system.
• In this, the initiator of the snapshot collection decides a future time at
which the snapshot is to be taken and broadcasts this time to every
process.
• All processes take their local snapshots at that instant in the global
time.
• However, a global physical clock is not available in a distributed
system and the following two issues need to be addressed in
recording of a consistent global snapshot of a distributed system
CHANDY–LAMPORT
ALGORITHM
Termination Detection
Termination Detection- System Model of a
Distributed computation

▪ A distributed computation consists of a fixed set of processes that


communicate solely by message passing.
▪ All messages are received correctly after an arbitrary but finite delay.
▪ Communication is asynchronous, i.e., a process never waits for the
receiver to be ready before sending a message.
▪ Messages sent over the same communication channel may not obey the
FIFO ordering.
▪ A distributed computation has the following characteristics:
1. Termination detection using Distributed Snapshots

▪ The algorithm uses the fact that a consistent snapshot of a distributed


system captures stable properties.

▪ Termination of a distributed computation is a stable property.

▪ Thus, if a consistent snapshot of a distributed computation is taken


after the distributed computation has terminated, the snapshot will
capture the termination of the computation.

▪ When a computation terminates, there must exist a unique process


which became idle last.
Formal Description
2. Termination detection by weight throwing
Termination detection by weight throwing - Algorithm
3. Spanning-tree-based termination detection algorithm
3. Spanning-tree-based termination detection algorithm
Example of Problem with the Simple algorithm
3. A spanning-tree-based termination detection algorithm( Correct algorithm)
Spanning-tree-based termination detection algorithm( Correct algorithm)- Eg.

You might also like