Professional Documents
Culture Documents
UNITT
Distributed
Exclusion
iutual
CONTENTS
Part-1 Distributed Mutual. ... 2-2B to 2-3B
Excusion : Classification of
Distributed Mutual Exclusion,
Requirement of Mutual
Exclusion Theorem
Part-2 Token Based and . . 2-3B to 2-10B
Non-Token Based
Algorithm, Performance
Metric for Distributed
Mutual Exclusion Algorithm
Part-3 Distributed Deadlock
.2-10B to 2-12B
*4e**isauo*****sie
Detection : System Model
Resource vs Communication
Deadlocks, Deadlock
Prevention, Avoidance, Detection &
Resolution
Part-4 Centralized Deadlock.
Detection, Distributed .2-12B
9********a4* to 2-18B
Deadlock Detection, Path-Pushing
Algorithm, Edge Chasing
Algorithms
2-1B (CS-Sem-7)
Distributed Mutual Exclusion
2-2 B (CS-Sem-7)
PART-1
Questions-Answers
distributed
Que 2.1. What do you by mutual exclusion in
mean
mutual exclusion
requirements of a good
system ? What
are
05
algorithm ? AKTU 2014-15, Marks
OR is
exclusion. What
of distributed mutual
classification
State the theorem?
mutual exclusion
requirement of 10
AKTU 2018-19, Marks
Answer
Mutual exclusion: relies on a
if the process
Mutual exclusion is problem that arises
a
a time.
1 one process at
can be used only by
r e s o u r c e that
common
resources is prevented.
access to shared
2. Concurrent request accesses
guarantees that only
one
Answer
Difference:
S.No. Mutual exclusion in Mutual exclusion in
distributed system single-computer
1. Shared memory does not Shared memory exists.
exist.
2. Both shared resources and Both shared resources and the
the users may be distributed. users are present in shared
memory.
3. Mutual exclusion problem is Mutual exclusion
solved by using message probiem is solved
by using shared variables
passing approach. approach i.e., semaphores.
Example
Lamport's algorithm:
In Lamport's algorithm, Vi:1si s N::R,= 1S, S .Syl. Every site S
which contains mutual exclusion requests
keeps a queue, request-queue;, to be delivered
ordered by their timestamps. This algorithm requires message
in the FIFO order between every pair
of sites.
Answer
Lamport's algorithm
1.
In Lamport's algorithm, Vi:1si sN::R, =18,S l .Every site
S, keeps a queue, request-queue, which contains mutual exclusion
requests ordered by their timestamps.
2. This algorithm requires message to be delivered in the FIFO order
between every pair of sites.
orithm:
1. Requesting the critical section:
a. When a site S, wants to enter the critical section (CS), it sends a
REQUEST ts, i) message to all the sites in its request set R, and
places the request on request-queue, Where (ts, i) is the timestamp
of the request.
b. When a site S, receives the REQUEST (ts, i) message from site S,
it returns a timestamped REPLY message to S, and places site S,s
request on the request-queue.
2-6B (CS-Sem-7) Distributed Mutual Exclusion
Answer
Suzuki-Kasami algorithm:
site attempting to enter the CS
1 In the Suzuki-Kasami's algorithm, ifa
broadcasts a request message for the
but does not have the token, it
token to all other sites.
section.
Algorithm
section:
1. Requesting theeritical increments
not have the token, then it
a. Ifthe requesting site S, does
(i, sn) message
and sends a REQUEST
its sequence number, RN,],
to all other sites. (sn
is the updated value of RN,lil).
Distributed System
2-7B (CS-Sem
it sets RN,[E] to m a r c
When site S, receives this message,
b. a
then it sends the token to R S, if
sn). If S, has the idle token,
LNi] +1.(LN[i] is the sequence
number oI the request that sisite
S
executed most recently).
2 Executing the critical section: received the token.
a. Site S, executes the CS when it has
Releasing the critical section: After finishing
the execution ofth.
the
CS, site S, takes the following actions
a.
It sets LN) element of the token array equal to RN,[i].
b. For every site S, whose ID is not in the token queue, it appends ite
ID to the token queue if RN,] = LNVI +1.
timestamps.
Performance: The Ricart-Agrawala algorithm requires 2(N-1) messages
per CS execution : (N - 1) REQUEST and (N - 1) REPLY messages.
Answer
Difference: Refer Q. 2.2, Page 2-3B, Unit-2.
Performance of mutual exclusion algorithm:
Performance of mutual exclusion algorithm is measured by the following
fourmetrics:
L Response Time (RT):It is time between R and CS i.e., time between
request message is sent out and completion of critical section.
Its request The site enters The site exits
CS request messages the CS the CS
arrives sent out
Synchronization Time
delay
Fig. 2.9.2.
Number ofmessage per CS:As number of message exchange redueo
the performance will improve.
aces,
System throughput: It is the rate at which the system executes t
the CS. If sd is the synchronization delay and E is the average criticsl
section time then the throughput is given by the following equation
1
System throughput = -
(sd+ E)
Maekawa 2T+ E 2T 5 N
3/N
Distributed Mutual Exclusion
2-10 B (CS-Sem-7)
PART-3
Model
Distributed Deadlock Detection System
Deadlock Prevention
Resource vs Communication Deadlocks,
Resolution
Avoidance, Detection &
Questions-Answers
conditions for
is deadlock ? What a r e necessary
Que 2.11. What
distributed system?
the oceurrence of deadlock in
Answer set of
of the process i.e., a
Deadlock is defined as the permanent blocking
other
for an event that is held by
process.
process is waiting
Necessary conditions for deadlock:
Mutual exclusion: A resource
can be held by at most one process.
1
can wait for
2. Hold and wait: Processes
that already hold resources
other resources.
from
No preemption:Aresource,
once granted, cannot be taken away
3.
execution.
a process till its complete
used
are waiting for resources
Answerr
Answer
PART-4|
Distributed Deadlock Detection,
Centralized Deadlock Detection,
Path-Pushing Algorithm, Edge Chasing
Algorithm.
Questions-Answers
a r e the deadlockhandling
strategies in distrik uted
Que 2.14.What
control organization for distributed deadi.
file system ? What is phan
detection ? Discuss
an algorithm
which can remove
phantom
AKTU 2016-17, Marks 05
deadlock.
OR
Explain edge chasing algorithm.
Answer
Deadlock handling strategies: Refer Q. 2.12, Page 2-10B, Unit-2.
Control organizations:Algorithm for detecting distributed deadlock can
be handled in following ways:
1. Centralized control
a. In centralized deadlock detection algorithms, a designated site
(control site) has the responsibility of constructing the global WFG
and searching it for cycles.
b.
b. Centralized deadlock detection algorithms are conceptualy simple
and are easy to implement.
2 Distributed control:
a. In these algorithms, the responsibility for detecting a global deadlock
is shared equally among all sites.
b. The global state graph is spread over many sites and several sites
participate in the detection of a global cycle.
3. Hierarchical control: In hierarchical deadlock detection algorithms,
sites are arranged in a hierarchical fashion, and a site detects deadlocks
involving only its descendant sites.
Ede chasing algorithm:
1 Edge chasing algorithm is used for phantom deadlock removal in
distributed systems.
2. In this, the global wait-for-graph is not constructed, but each of the
servers involved has knowledge about some of its edges.
3. The servers attempt to find cycles by forwarding messages called probes,
which follows the edges of the graph throughout the distributed system.
4. A probe message consists of transactions wait-for-relationship
representing a path in the global wait-for-graph.
5. Edge chasing has three steps
a. Initiation: The server initiates to deteet deadlock.
b. Detection : Detection consists of receiving probes and deciding
whether deadlock has occurred and forward
probes.
C. Resolution: When a cycle detected, a transaction in the cycle is
aborted to break deadlock.
Distributed Mutual Exclusion
2-14 B (CS-Sem-7)
distributed
the deadlock handling strategies in
Que 2.15.|Give
differences in centralized, distributed and
system? What are
thefor distributed deadlock
hierarchical control organizations
detection?
2014-15, Marks 10
AKTU
Answer
Unit-2.
Deadlock handling strategies : Refer Q. 2.12, Page 2-10B,
Difference:
S. No.Centralized control Distributed control Hierarchical control|
Descendant site can
1 A control site has the| All sites have the| detect a
responsibility to detect responsibility to detect| global wait|
global wait for graph. |a global wait for graph. for graph.
Have single point of| No single point of| No single point of
2
failure. failure. failure.
d The control site checks the WFG for deadlocks whenever a request
edge is added to the WFG.
The Ho-Ramamoorthy algorithms: Ho and Ramamoorthy gave
two centralized deadlock detection algorithms called two-phase and one-
phase algorithms.
a. The two-phase algorithm
In the two-phase algorithm, every site maintains a status table
that contains the status of all the processes initiated at that
side.
ii. Periodically, a designated site requests the status table from
all sites, constructs a WFG from the information received, and
searches it for cycles.
ii. If there is no cycle, then the system is free from deadlocks,
otherwise, the designated site again requests status tables
from all the sites and again constructs a WFG using only those
transactions which are common to both reports.
iv. If the same cycle is detected again, the system is declared
deadlocked.
b. The one-phase algorithm:
L
The one-phase algorithm requires only one status report from
each site; however each site maintains two status tables; a
resource status table and a process status table.
The resource status table at a site keeps track of the
.
transactions that have locked or are waiting for resources
stored at that site.
detection
various hierarchical deadlock
Que2.18.| Explain
algorithms.
Answer
hierarchical fashion,
sites are logically arranged in
In hierarchical algorithms, deadlocks involving only its children
for detecting
and a site is responsible
sites.
Distributed System 2-17 B(CS-Sem-7
deadlock detection algorithm8:
Various hierarchical
1. The Menasce-Muntz Algorithm:
a. In this algorithm all the controllers are arranged in tree fashin
b. The controllers at the bottom-most level (leafcontrollers) manao
resources and others (non-leaf controllers) are responsible for
deadlock detection.
C. Whenever a change occurs in a controller's TWF (Transa) graph
due to a resources allocation, wait or release, it is propagated to its
parent controller.
d. The parent controller makes changes in its TWF graph, searches
for cycles, and
propagates the changes upward, if necessary.
e. Anon-leaf controller can receive up-to-date information concerning
the TWF graph of its children
continuously or periodically.
2 The Ho-Ramamoorthy algorithm:
a. In this algorithm, sites are
grouped into several disjoint clusters.
b. Periodically, a site is chosen
as a central control
dynamically chooses a control site for each cluster. site, which
C. The central control site
requests from every control site their
intercluster transaction status information
and wait-for relations.
Control
site
Control Central
site site
Control
O site
Fig. 2.18.1. O
d As a result, a control
cluster and applie site collects status
plies the
detect all deadloc
ocks one-phase deadlock
involving
table from
all the sit
only detection sites in its
intracluster algorith1thm to
transactions.
2-18 B (CS-Sem-7)
Distributed Mutual Exclusion
e. Then, it sends intercluster transaction status
for relations to the central information and wait-
control site.
f. The central site split the
intercluster
constructs a system WFG, and searches information it receives,
it for cycles.
g. Thus, a control site detects all deadlocks located in its
the central control site detects all cluster, and
intercluster deadlocks.