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

Distributed System UNIT - III

Distributed System UNIT -III
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)
39 views

Distributed System UNIT - III

Distributed System UNIT -III
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/ 23

UNIT III

PART -A
1.What are the different models of deadlocks?
Various deadlock handling strategies in the distributed system are as follows:
There are mainly three approaches to handling deadlocks:
• Deadlock prevention
• Deadlock avoidance
• Deadlock detection
2.What is the purpose of the wait-for-graph (WFG)? Give an example for WFG?
In the blocked state, a process is waiting to acquire some resource. The state of the system can be
modeled by directed graph, called a wait for graph (WFG).
In a WFG , nodes are processes and there is a directed edge from node P1 to mode P2 if P1 is
blocked and is waiting for P2 to release some resource.
3.What is the purpose of associating timestamp with events in Lamport’s algorithm?
Lamport timestamps can be used to create a total ordering of events in a distributed system by
using some arbitrary mechanism to break ties.
4.Define deadlock?
Deadlock is a state of a database system having two or more transactions, when each transaction is
waiting for a data item that is being locked by some other transaction. A deadlock can be indicated by a
cycle in the wait-for-graph.
5.Name the two types of messages used by Ricart-agrawala algorithm ?
The Ricart-Agrawala algorithm assumes the communication channels are FIFO. The algorithm uses
two types of messages: REQUEST and REPLY.
6.What are the conditions for deadlock?
The four necessary conditions for a deadlock situation are
• Mutual exclusion
• No preemption
• Hold and wait
• Circular set.
7. What is meant by Deadlock prevention?
It is achieved by either having a process acquire all the needed resources simultaneously before it
begins execution or by pre-empting a process that holds the needed resource.
8. Write about dead lock avoidance?
In the deadlock avoidance approach to distributed systems, a resource is granted to a process if the
resulting global system is safe. Deadlock detection requires an examination of the status of the process-
resources interaction for the presence of a deadlock condition.
9. Define mutual exclusion?
Mutual exclusion in a distributed system states that only one process is allowed to execute the critical
section (CS) at any given time.
10. Define Message complexity?
This is the number of messages that are required per CS execution by a site.
11. What is Synchronization delay?
After a site leaves the CS, it is the time required and before the next site enters the CS.
12. Give the Performance of Lamport's algorithm?
Synchronization delay is equal to maximum message transmission time. It requires 3(N-1) messages
per CS execution. Algorithm can be optimized to 2(N-1) messages by omitting the REPLY message in
some situations.
13.Define Response time?
This is the time interval a request waits for its CS execution to be over after its request messages
have been sent out. Thus, response time does not include the time a request waits at a site before its
request messages have been sent out.
14.Define System throughput?
This is the rate at which the system executes requests for the CS. If SD is the synchronization delay
and E is the average critical section execution time.
System throughput = 1/(SD+E).
15.What is the Message Complexity of Lamport's algorithm?
Lamport's Algorithm requires invocation of 3(N-1) messages per critical section execution.
These 3(N-1) messages involves
• (N-1) request messages
• (N-1) reply messages
• (N-1) release messages
16. List the drawbacks of Lamport's Algorithm?
Unreliable approach: failure of any one of the processes will halt the progress of entire system.
High message complexity: Algorithm requires 3(N-1) messages per critical section invocation.
17.Give the Performance of Lamport's algorithm?
Synchronization delay is equal to maximum message transmission time. It requires 3(N-1) messages
per CS execution. Algorithm can be optimized to 2(N-1) messages by omitting the REPLY message in
some situations.
18.What is the use of Ricart-Agrawala algorithm?
It is an algorithm to for mutual exclusion in a distributed system proposed by Glenn Ricart and Ashok
Agrawala. This algorithm is an extension and optimization of Lamport's Distributed Mutual Exclusion
Algorithm.. It follows permission based approach to ensure mutual exclusion.
19.Give the Drawbacks and performance of Ricart-Agrawala algorithm?
Unreliable approach: failure of any one of node in the system can halt the progress of the system. In
this situation, the process will starve forever. The problem of failure of node can be solved by detecting
failure after some timeout.
Performance:
Synchronization delay is equal to maximum message transmission time It requires 2(N-1) messages per
Critical section execution
20.What is Mackawa's Algorithm?
It is quorum based approach to ensure mutual exclusion in distributed systems. In permission based
algorithms like Lamport's Algorithm, Ricart-Agrawala Algorithm etc. a site request permission from
every other site but in quorum based approach, a site does not request permission from every other
site but from a subset of sites which is called quorum.
21.What is the Message Complexity Maekawa's Algorithm?
This requires invocation of 3 √N messages per critical section execution as the size of request set is
√N. These 3√N messages involves.
• √N request messages
• √N reply messages
• √N release messages
22.List the drawbacks of Maekawa's Algorithm?
This algorithm is deadlock prone because a site is exclusively locked by other sites and requests are
not prioritized by their timestamp.
23.Give the Performance of Maekawa's Algorithm?
Synchronization delay is equal to twice the message propagation delay time. It requires 3√n
messages per critical section execution.
24.What is Suzuki-Kasami algorithm?
It is a token-based algorithm for achieving mutual exclusion in distributed systems. This is
modification of Ricart-Agrawala algorithm, a permission based (Non- token based) algorithm which
uses REQUEST and REPLY messages to ensure mutual exclusion.
25.Give the Message Complexity of Suzuki-Kasami algorithm?
The algorithm requires 0 message invocation if the site already holds the idle token at the time of
critical section request or maximum of N message per critical section execution. This N messages
involves

• (N-1) request messages


• 1 reply message
26.Give the drawbacks of Suzuki-Kasami Algorithm?
Non-symmetric Algorithm: A site retains the token even if it does not have requested for critical
section.
27.Give the Performance of Suzuki-Kasami algorithm?
Synchronization delay is 0 and no message is needed if the site holds the idle token at the time of
its request. In case site does not holds the idle token, the maximum synchronization delay is equal to
maximum message transmission time and a maximum of N message is required per critical section
invocation.
28.Define Centralized approach?
Here there is only one responsible resource to detect deadlock
The advantage of this approach is that it is simple and easy to implement, while the drawbacks include
excessive workload at one node, single point failure which in turns makes the system less reliable.
29.What is Distributed approach?
In the distributed approach different nodes work together to detect deadlocks. No single point
failure as workload is equally divided among all nodes.
The speed of deadlock detection also increases.
30.What is Hierarchical approach?
This approach is the most advantageous approach.
It is the combination of both centralized and distributed approaches of deadlock detection in a
distributed system.
In this approach, some selected nodes or cluster of nodes are responsible for deadlock detection and
these selected nodes are controlled by a single node.
31.Define Wait for graph?
This is used for deadlock deduction. A graph is drawn based on the request and acquirement of the
resource. If the graph created has a closed loop or a cycle, then there is a deadlock.
32.What is Deadlock prevention?
This is achieved either by having a process acquire all the needed resources simultaneously before
it begins executing or by preempting a process which holds the needed resource.
This approach is highly inefficient and impractical in distributed systems.
33.What is Deadlock avoidance?
A resource is granted to a process if the resulting global system state is safe This is impractical in
distributed systems.
34.What is Deadlock detection?
This requires examination of the status of process-resource interactions for presence of cyclic wait.
Deadlock detection in distributed systems seems to be the best approach to handle deadlocks in
distributed systems.
35.What is Single Resource Model?
A process can have at most one outstanding request for only one unit of a resource The maximum
out-degree of a node in a WFG for the single resource model can be l the presence of a cycle in the
WFG shall indicate that there is a deadlock.
36.How to detect deadlock in OR model?
Deadlock in OR model: a process Pi is blocked if it has a pending OR request to be Satisfied.
37.What are the four classes of distributed deadlock detection algorithm?
1. Path-pushing
2. Edge-chasing
3. Diffusion computation
4. Global state detection
38.What are Path Pushing algorithms ?
In path pushing algorithm, the distributed deadlock detection are detected by maintaining an
explicit global wait for graph.
The basic idea is to build a global WFG (Wait For Graph) for each site of the distributed system.
At each site whenever deadlock computation is performed, it sends its local WFG to all the
neighbouring sites.
39.Write about Edge Chasing Algorithms?
The presence of a cycle in a distributed graph structure is be verified by propagating special
messages called probes, along the edges of the graph.
These probe messages are different than the request and reply messages.
The formation of cycle can be deleted by a site if it receives the matching probe sent by it previously.
40.Brief about the Diffusing Computation Based Algorithms ?
In diffusion computation based distributed deadlock detection algorithms, deadlock detection
computation is diffused through the WFG of the system.
These algorithms make use of echo algorithms to detect deadlocks.
41.Write about Global state detection-based algorithms?
Global state detection based deadlock detection algorithms exploit the following facts:
1. A consistent snapshot of a distributed system can be obtained without freezing the underlying
computation.
2. If a stable property holds in the system before the snapshot collection is initiated, this property will
still hold in the snapshot.
42.Explain the features of Mitchell and Merritt's algorithm?
1. Only one process in a cycle detects the deadlock. This simplifies the deadlock resolution - this
process can abort itself to resolve the deadlock. This algorithm can be improvised by including
priorities, and the lowest priority process in a cycle detects deadlock and aborts.
2. In this algorithm, a process that is detected in deadlock is aborted spontaneously. even though
under this assumption phantom deadlocks cannot be excluded. It can be shown, however, that only
genuine deadlocks will be detected in the absence of spontaneous aborts.
43.What are the transitions defined by the Mitchell and Merritt's algorithm?
Block creates an edge in the WFG.
Two messages are needed, one resource request and onemessage back to the blocked process to
inform it of the public label of the process it is waiting for.
Activate denotes that a process has acquired the resource from the process it was waiting for.
Transmit propagates larger labels in the opposite direction of the edges by sending a probe message.
Detect means that the probe with the private label of some process has returned to it, indicating a
deadlock.
44.What is the use of probe in Chandy-Misra-Haas algorithm?
Each probe message contains the following information:
the id of the process that is blocked (the one that initiates the probe message);
the id of the process is sending this particular version of the probe message;
the id of the process that should receive this probe message.
45.Give the advantages of Chandy-Misra-Haas algorithm?
It is easy to implement.
Each probe message is of fixed length.
There is very little computation.
There is very little overhead.
There is no need to construct a graph, nor to pass graph information to other sites.
This algorithm does not find false (phantom) deadlock.
There is no need for special data structures.

PART-B
1.Explain Maekawa’s algorithm for mutual exclusion in distributed system and its drawbacks?
MAEKAWA‘s ALGORITHM
• Maekawa’s Algorithm is quorum based approach to ensure mutual exclusion in distributed
systems.
• In permission based algorithms like Lamport’s Algorithm, Ricart-Agrawala Algorithm etc. a site
request permission from every other site but in quorum based approach, a site does not request
permission from every other site but from a subset of sites which is called quorum.
• Three type of messages ( REQUEST, REPLY and RELEASE) are used.
• A site send a REQUEST message to all other site in its request set or quorum to get their
permission to enter critical section.
• A site send a REPLY message to requesting site to give its permission to enter the critical section.
• A site send a RELEASE message to all other site in its request set or quorum upon exiting the
critical section.
The following are the conditions for Maekawa’s algorithm:

Maekawa used the theory of projective planes and showed that N = K(K – 1)+ 1. This relation gives
|Ri|= √N.

To enter Critical section:


• When a site Si wants to enter the critical section, it sends a request message REQUEST(i) to all
other sites in the request set Ri.
• When a site Sj receives the request message REQUEST(i) from site Si, it returns a REPLY message
to site Si if it has not sent a REPLY message to the site from the time it received the last RELEASE
message. Otherwise, it queues up the request.
To execute the critical section:
• A site Si can enter the critical section if it has received the REPLY message from all
the site in request set Ri.
To release the critical section:
• When a site Si exits the critical section, it sends RELEASE(i) message to all other sites in request
set Ri.
• When a site Sj receives the RELEASE(i) message from site Si, it send REPLY message to the next
site waiting in the queue and deletes that entry from the queue.
• In case queue is empty, site Sj update its status to show that it has not sent any REPLY message
since the receipt of the last RELEASE message.
Correctness Theorem:
Maekawa’s algorithm achieves mutual exclusion.
Proof:
Proof is by contradiction.
▪ Suppose two sites Si and Sj are concurrently executing the CS.
▪ This means site Si received a REPLY message from all sites in Ri and concurrently site Sj was able
to receive a REPLY message from all sites in Rj .
▪ If Ri ∩ Rj = {Sk }, then site Sk must have sent REPLY messages to both Si and Sj concurrently, which
is a contradiction.
Message Complexity:
Maekawa’s Algorithm requires invocation of 3√N messages per critical section execution as the
size of a request set is √N.
These 3√N messages involves.
• √N request messages
• √N reply messages
• √N release messages
Drawbacks of Maekawa’s Algorithm:
This algorithm is deadlock prone because a site is exclusively locked by other sites and requests are
not prioritized by their timestamp.
Performance:
Synchronization delay is equal to twice the message propagation delay time. It requires 3√n
messages per critical section execution.

2.Discuss with suitable example to show that a deadlock cannot occur if any one of the four
conditions is absent? (or)How we can achieve deadlock detection in distributed system ?Provide
various models to carry out the same?
Deadlock can neither be prevented nor avoided in distributed system as the system is so vast that
it is impossible to do so. Therefore, only deadlock detection can be implemented. The techniques
of deadlock detection in the distributed system require the following:
• Progress:The method should be able to detect all the deadlocks in the system.
• Safety: The method should not detect false of phantom deadlocks.
There are three approaches to detect deadlocks in distributed systems.
Centralized approach:

• Here there is only one responsible resource to detect deadlock.


• The advantage of this approach is that it is simple and easy to implement, while the drawbacks
include excessive workload at one node, single point failure which in turns makes the system less
reliable.
Distributed approach:
• In the distributed approach different nodes work together to detect deadlocks. No single point
failure as workload is equally divided among all nodes.
• The speed of deadlock detection also increases.
Hierarchical approach:
• This approach is the most advantageous approach.
• It is the combination of both centralized and distributed approaches of deadlock detection in a
distributed system.
• In this approach, some selected nodes or cluster of nodes are responsible for deadlock detection
and these selected nodes are controlled by a single node.
Wait for graph :
This is used for deadlock deduction. A graph is drawn based on the request and acquirement of the
resource. If the graph created has a closed loop or a cycle, then there is a deadlock.
Deadlock Handling Strategies :
Handling of deadlock becomes highly complicated in distributed systems because no site has
accurate knowledge of the current state of the system and because every inter-site communication
involves a finite and unpredictable delay. There are three strategies for handling deadlocks:
• Deadlock prevention:
−This is achieved either by having a process acquire all the needed resources simultaneously
before it begins executing or by preempting a process which holds the needed resource. − This
approach is highly inefficient and impractical in distributed systems.
• Deadlock avoidance:
− A resource is granted to a process if the resulting global system state is safe. This is impractical in
distributed systems.
• Deadlock detection:
−This requires examination of the status of process-resource interactions for presence of cyclic
wait.
− Deadlock detection in distributed systems seems to be the best approach to handle deadlocks in
distributed systems.
Issues in deadlock Detection Deadlock handling faces two major issues
1. Detection of existing deadlocks
2. Resolution of detected deadlocks
Deadlock Detection
− Detection of deadlocks involves addressing two issues namely maintenance of the WFG and
searching of the WFG for the presence of cycles or knots.
− In distributed systems, a cycle or knot may involve several sites, the search for cycles greatly
depends upon how the WFG of the system is represented across the system.
− Depending upon the way WFG information is maintained and the search for cycles is carried out,
there are centralized, distributed, and hierarchical algorithms for deadlock detection in distributed
systems.
Correctness criteria:
A deadlock detection algorithm must satisfy the following two conditions:
1. Progress-No undetected deadlocks:
The algorithm must detect all existing deadlocks in finite time. In other words, after all
wait-for dependencies for a deadlock have formed, the algorithm should not wait for any
more events to occur to detect the deadlock.
2. Safety -No false deadlocks:
The algorithm should not report deadlocks which do not exist.This is also called as called
phantom or false deadlocks.
Resolution of a Detected Deadlock:
• Deadlock resolution involves breaking existing wait-for dependencies between the processes to
resolve the deadlock.
• It involves rolling back one or more deadlocked processes and assigning their resources to
blocked processes so that they can resume execution.
• The deadlock detection algorithms propagate information regarding wait-for dependencies
along the edges of the wait-for graph.
• When a wait-for dependency is broken, the corresponding information should be immediately
cleaned from the system.
• If this information is not cleaned in a timely manner, it may result in detection of phantom
deadlocks.

3.Outline Lamport’s algorithm with an example?


LAMPORT’S ALGORITHM
Lamport’s Distributed Mutual Exclusion Algorithm is a permission based algorithm proposed by
Lamport as an illustration of his synchronization scheme for distributed systems.
• In permission based timestamp is used to order critical section requests and to resolve any
conflict between requests.
• In Lamport’s Algorithm critical section requests are executed in the increasing order of
timestamps i.e a request with smaller timestamp will be given permission to execute critical
section first than a request with larger timestamp.
• Three type of messages ( REQUEST, REPLY and RELEASE) are used and communication channels
are assumed to follow FIFO order.
• A site send a REQUEST message to all other site to get their permission to enter critical section.
• A site send a REPLY message to requesting site to give its permission to enter the critical section.
• A site send a RELEASE message to all other site upon exiting the critical section.
• Every site Si, keeps a queue to store critical section requests ordered by their timestamps.
• request_queuei denotes the queue of site Si.
• A timestamp is given to each critical section request using Lamport’s logical clock.
• Timestamp is used to determine priority of critical section requests. Smaller timestamp gets high
priority over larger timestamp. The execution of critical section request is always in the order of
their timestamp.
To enter Critical section:
When a site Si wants to enter the critical section, it sends a request message Request(tsi, i) to
all other sites and places the request on request_queuei. Here, Tsi denotes the timestamp of Site
Si.
When a site Sj receives the request message REQUEST(tsi, i) from site Si, it returns a
timestamped REPLY message to site Si and places the request of site Si on request_queuej

To execute the critical section:


A site Si can enter the critical section if it has received the message with timestamp larger than
(tsi, i) from all other sites and its own request is at the top of request_queuei.
To release the critical section:
▪ When a site Si exits the critical section, it removes its own request from the top of its request
queue and sends a timestamped RELEASE message to all other sites. When a site Sj receives the
timestamped RELEASE message from site Si, it removes the request of Sia from its request queue.

Correctness :
Theorem:
Lamport’s algorithm achieves mutual exclusion.
Proof:
Proof is by contradiction.
▪ Suppose two sites Si and Sj are executing the CS concurrently. For this to happen conditions L1
and L2 must hold at both the sites concurrently.
▪ This implies that at some instant in time, say t, both Si and Sj have their own requests at the top
of their request queues and condition L1 holds at them. Without loss of generality, assume that Si
’s request has smaller timestamp than the request of Sj .
▪ From condition L1 and FIFO property of the communication channels, it is clear that at instant t
the request of Si must be present in request queuej when Sj was executing its CS. This implies that
Sj ’s own request is at the top of its own request queue when a smaller timestamp request, Si ’s
request, is present in the request queuej – a contradiction!
Theorem:
Lamport’s algorithm is fair.
Proof:
The proof is by contradiction.
▪ Suppose a site Si ’s request has a smaller timestamp than the request of another site Sj and Sj is
able to execute the CS before Si .
▪ For Sj to execute the CS, it has to satisfy the conditions L1 and L2. This implies that at some
instant in time say t, Sj has its own request at the top of its queue and it has also received a
message with timestamp larger than the timestamp of its request from all other sites.
▪ But request queue at a site is ordered by timestamp, and according to our assumption Si has
lower timestamp. So Si ’s request must be placed ahead of the Sj ’s request in the request queuej .
This is a contradiction!
Message Complexity:
Lamport’s Algorithm requires invocation of 3(N – 1) messages per critical section execution.
These 3(N – 1) messages involves
• (N – 1) request messages
• (N – 1) reply messages
• (N – 1) release messages
Drawbacks of Lamport’s Algorithm:
• Unreliable approach: failure of any one of the processes will halt the progress of entire system.
• High message complexity: Algorithm requires 3(N-1) messages per critical section invocation.
Performance:
Synchronization delay is equal to maximum message transmission time. It requires 3(N – 1)
messages per CS execution. Algorithm can be optimized to 2(N – 1) messages by omitting the
REPLY message in some situations.

4.Discuss in detail the requirements that mutual exclusion algorithm should satisfy and discuss
what matric we use to measure the performance of mutual exclusion algorithm?
DISTRIBUTED MUTUAL EXCLUSION ALGORITHMS :
• Mutual exclusion is a concurrency control property which is introduced to prevent race
conditions.
• It is the requirement that a process cannot access a shared resource while another concurrent
process is currently present or executing the same resource. Mutual exclusion in a distributed
system states that only one process is allowed to execute the critical section (CS) at any given time.
• Message passing is the sole means for implementing distributed mutual exclusion.
• The decision as to which process is allowed access to the CS next is arrived at by message
passing, in which each process learns about the state of all other processes in some consistent
way.
• There are three basic approaches for implementing distributed mutual exclusion:
1. Token-based approach:
− A unique token is shared among all the sites.
− If a site possesses the unique token, it is allowed to enter its critical section
− This approach uses sequence number to order requests for the critical section.
− Each requests for critical section contains a sequence number. This sequence number is used
to distinguish old and current requests. − This approach insures Mutual exclusion as the token
is unique.
− Eg: Suzuki-Kasami’s Broadcast Algorithm.
2.Non-token-based approach:
− A site communicates with other sites in order to determine which sites should execute
critical section next. This requires exchange of two or more successive round of messages
among sites.
− This approach use timestamps instead of sequence number to order requests for the critical
section. − When ever a site make request for critical section, it gets a timestamp. Timestamp is
also used to resolve any conflict between critical section requests.
− All algorithm which follows non-token based approach maintains a logical clock. Logical
clocks get updated according to Lamport’s scheme.
− Eg: Lamport's algorithm, Ricart–Agrawala algorithm.
3.Quorum-based approach:
− Instead of requesting permission to execute the critical section from all other sites, Each
site requests only a subset of sites which is called a quorum.
− Any two subsets of sites or Quorum contains a common site.
− This common site is responsible to ensure mutual exclusion.
− Eg: Maekawa’s Algorithm.
Preliminaries:
• The system consists of N sites, S1, S2, S3, …, SN.
• Assume that a single process is running on each site.
• The process at site Si is denoted by pi. All these processes communicate asynchronously over an
underlying communication network.
• A process wishing to enter the CS requests all other or a subset of processes by sending REQUEST
messages, and waits for appropriate replies before entering the CS.
• While waiting the process is not allowed to make further requests to enter the CS.
• A site can be in one of the following three states: requesting the CS, executing the CS, or neither
requesting nor executing the CS.
• In the requesting the CS state, the site is blocked and cannot make further requests for the CS.
• In the idle state, the site is executing outside the CS.
• In the token-based algorithms, a site can also be in a state where a site holding the token is
executing outside the CS. Such state is referred to as the idle token state.
• At any instant, a site may have several pending requests for CS. A site queues up these requests
and serves them one at a time.
• N denotes the number of processes or sites involved in invoking the critical section, T denotes the
average message delay, and E denotes the average critical section execution time. Requirements of
mutual exclusion algorithms:
• Safety property:
The safety property states that at any instant, only one process can execute the critical section. This
is an essential property of a mutual exclusion algorithm.
• Liveness property:
This property states the absence of deadlock and starvation. Two or more sites should not endlessly
wait for messages that will never arrive. In addition, a site must not wait indefinitely to execute the
CS while other sites are repeatedly executing the CS. That is, every requesting site should get an
opportunity to execute the CS in finite time.
• Fairness:
Fairness in the context of mutual exclusion means that each process gets a fair chance to execute
the CS. In mutual exclusion algorithms, the fairness property generally means that the CS execution
requests are executed in order of their arrival in the system.
Performance metrics
➢ Message complexity: This is the number of messages that are required per CS execution by a
site.
➢ Synchronization delay: After a site leaves the CS, it is the time required and before the next site
enters the CS. (Figure 3.1)
➢ Response time: This is the time interval a request waits for its CS execution to be over after its
request messages have been sent out. Thus, response time does not include the time a request
waits at a site before its request messages have been sent out. (Figure 3.2)
➢ System throughput: This is the rate at which the system executes requests for the CS. If SD is the
synchronization delay and E is the average critical section execution time.

Low and High Load Performance:


▪ The performance of mutual exclusion algorithms is classified as two special loading conditions,
viz., “low load” and “high load”.
▪ The load is determined by the arrival rate of CS execution requests.
▪ Under low load conditions, there is seldom more than one request for the critical section present
in the system simultaneously.
▪ Under heavy load conditions, there is always a pending request for critical section at a site.
Best and worst case performance :
▪ In the best case, prevailing conditions are such that a performance metric attains the best possible
value. For example, the best value of the response time is a roundtrip message delay plus the CS
execution time, 2T +E.
▪ For examples, the best and worst values of the response time are achieved when load is,
respectively, low and high;
▪ The best and the worse message traffic is generated at low and heavy load conditions,
respectively.

5.Explain Ricart-Agrawala algorithm with diagram?


RICART–AGRAWALA ALGORITHM :
• Ricart–Agrawala algorithm is an algorithm to for mutual exclusion in a distributed system
proposed by Glenn Ricart and Ashok Agrawala.
• This algorithm is an extension and optimization of Lamport’s Distributed Mutual Exclusion
Algorithm.
• It follows permission based approach to ensure mutual exclusion.
• Two type of messages ( REQUEST and REPLY) are used and communication channels are assumed
to follow FIFO order.
• A site send a REQUEST message to all other site to get their permission to enter critical section.
• A site send a REPLY message to other site to give its permission to enter the critical section.
• A timestamp is given to each critical section request using Lamport’s logical clock.
• Timestamp is used to determine priority of critical section requests.
• Smaller timestamp gets high priority over larger timestamp.
• The execution of critical section request is always in the order of their timestamp.
To enter Critical section:
• When a site Si wants to enter the critical section, it send a timestamped REQUEST message to all
other sites.
• When a site Sj receives a REQUEST message from site Si, It sends a REPLY message to site Si if and
only if Site Sj is neither requesting nor currently executing the critical section.
• In case Site Sj is requesting, the timestamp of Site Si‘s request is smaller than its own request.
• Otherwise the request is deferred by site Sj.
To execute the critical section:
Site Si enters the critical section if it has received the REPLY message from all other sites.
To release the critical section:
Upon exiting site Si sends REPLY message to all the deferred requests.
Performance:
Synchronization delay is equal to maximum message transmission time It requires 2(N – 1)
messages per Critical section execution.
Drawbacks of Ricart–Agrawala algorithm:
• Unreliable approach: failure of any one of node in the system can halt the progress of the
system. In this situation, the process will starve forever. The problem of failure of node can be
solved by detecting failure after some timeout.
.
Theorem:
Ricart-Agrawala algorithm achieves mutual exclusion.
Proof:
Proof is by contradiction.
▪ Suppose two sites Si and Sj ‘ are executing the CS concurrently and Si ’s request has higher
priority than the request of Sj . Clearly, Si received Sj ’s request after it has made its own request.
▪ Thus, Sj can concurrently execute the CS with Si only if Si returns a REPLY to Sj (in response to Sj ’s
request) before Si exits the CS.
▪ However, this is impossible because Sj ’s request has lower priority. Therefore, Ricart-Agrawala
algorithm achieves mutual exclusion.
Message Complexity:
Ricart–Agrawala algorithm requires invocation of 2(N – 1) messages per critical section execution.
These 2(N – 1) messages involve:
• (N – 1) request messages
• (N – 1) reply messages

6.Explain Suzuki-Kasami’s algorithm wuth diagram?


SUZUKI–KASAMI‘s BROADCAST ALGORITHM
• Suzuki–Kasami algorithm is a token-based algorithm for achieving mutual exclusion in distributed
systems.
• This is modification of Ricart–Agrawala algorithm, a permission based (Non-token based)
algorithm which uses REQUEST and REPLY messages to ensure mutual exclusion.
• In token-based algorithms, A site is allowed to enter its critical section if it possesses the unique
token.
• Non-token based algorithms uses timestamp to order requests for the critical section where as
sequence number is used in token based algorithms.
• Each requests for critical section contains a sequence number. This sequence number is used to
distinguish old and current requests.
To enter Critical section:
• When a site Si wants to enter the critical section and it does not have the token then it
increments its sequence number RNi[i] and sends a request message REQUEST(i, sn) to all other
sites in order to request the token.
• Here sn is update value of RNi[i]
• When a site Sj receives the request message REQUEST(i, sn) from site Si, it sets RNj[i] to
maximum of RNj[i] and sni.eRNj[i] = max(RNj[i], sn). After updating RNj[i], Site Sj sends the token
to site Si if it has token and RNj[i] = LN[i] + 1

To execute the critical section:


• Site Si executes the critical section if it has acquired the token.
To release the critical section:
After finishing the execution Site Si exits the critical section and does following:
• sets LN[i] = RNi[i] to indicate that its critical section request RNi[i] has been executed
• For every site Sj, whose ID is not prsent in the token queue Q, it appends its ID to Q if RNj[j] =
LN[j] + 1 to indicate that site Sj has an outstanding request.
• After above updation, if the Queue Q is non-empty, it pops a site ID from the Q and sends the
token to site indicated by popped ID.
• If the queue Q is empty, it keeps the token.
Correctness
Mutual exclusion is guaranteed because there is only one token in the system and a site holds the
token during the CS execution.
Theorem:
A requesting site enters the CS in finite time.
Proof:
Token request messages of a site Si reach other sites in finite time.
Since one of these sites will have token in finite time, site Si ’s request will be placed in the token
queue in finite time. Since there can be at most N − 1 requests in front of this request in the token
queue, site Si will get the token and execute the CS in finite time.
Message Complexity:
The algorithm requires 0 message invocation if the site already holds the idle token at the time of
critical section request or maximum of N message per critical section execution.
This N messages involves
• (N – 1) request messages
• 1 reply message
Drawbacks of Suzuki–Kasami Algorithm:
• Non-symmetric Algorithm: A site retains the token even if it does not have requested for critical
section.
Performance:
Synchronization delay is 0 and no message is needed if the site holds the idle token at the time of
its request. In case site does not holds the idle token, the maximum synchronization delay is equal
to maximum message transmission time and a maximum of N message is required per critical
section invocation.
7.Expalin about model of deadlock?
The models of deadlocks are explained based on their hierarchy. The diagrams illustrate the
working of the deadlock models. Pa, Pb, Pc, Pd are passive processes that had already acquired the
resources. Pe is active process that is requesting the resource.
Single Resource Model :
• A process can have at most one outstanding request for only one unit of a resource.
• The maximum out-degree of a node in a WFG for the single resource model can be 1, the
presence of a cycle in the WFG shall indicate that there is a deadlock.
AND Model:
• In the AND model, a passive process becomes active (i.e., its activation condition is fulfilled) only
after a message from each process in its dependent set has arrived.
• In the AND model, a process can request more than one resource simultaneously and the
request is satisfied only after all the requested resources are granted to the process.
• The requested resources may exist at different locations.
• The out degree of a node in the WFG for AND model can be more than 1.
• The presence of a cycle in the WFG indicates a deadlock in the AND model.
• Each node of the WFG in such a model is called an AND node .
In the AND model, if a cycle is detected in the WFG, it implies a deadlock but not vice versa. That
is, a process may not be a part of a cycle, it can still be deadlocked.

OR Model
• In the OR model, a passive process becomes active only after a message from any process in its
dependent set has arrived.
• This models classical nondeterministic choices of receive statements.
• A process can make a request for numerous resources simultaneously and the request is satisfied
if any one of the requested resources is granted.
• The requested resources may exist at different locations.
• If all requests in the WFG are OR requests, then the nodes are called OR nodes.
• Presence of a cycle in the WFG of an OR model does not imply a deadlock in the OR model.
• In the OR model, the presence of a knot indicates a deadlock.
Deadlock in OR model:
a process Pi is blocked if it has a pending OR request to be satisfied.
• With every blocked process, there is an associated set of processes called dependent set.
• A process shall move from an idle to an active state on receiving agrant message from any of the
processes in its dependent set.
• A process ispermanently blocked if it never receives a grant message from any of the processes
in its dependent set.
• A set of processes S is deadlockedif all the processes in S are permanently blocked.
• In short, a processis deadlocked or permanently blocked, if the following conditions are met: 1.
Each of the process is the set S is blocked. 2. The dependent set for each process in S is a subset of
S. 3. No grant message is in transit between any two processes in set S.
• A blocked process P is the set S becomes active only after receiving a grant message
from a process in its dependent set, which is a subset of S.

4 Model (p out of q model)


• This is a variation of AND-OR model.
• This allows a request to obtain any k available resources from a pool of n resources. Both the
models are the same in expressive power.
• This favours more compact formation of a request.
• Every request in this model can be expressed in the AND-OR model and vice-versa.
• Note that AND requests for p resources can be stated as and OR requests for p resources can be
stated as(p i)

Unrestricted model :
• No assumptions are made regarding the underlying structure of resource requests.
• In this model, only one assumption that the deadlock is stable is made and hence it is the most
general model.
• This way of looking at the deadlock problem helps in separation of concerns: concerns about
properties of the problem are separated from underlying distributed systems computations.
Hence, these algorithms can be used to detect other stable properties as they deal with this
general model.
• These algorithms are of more theoretical value for distributed systems since no further
assumptions are made about the underlying distributed systems computations which leads to a
great deal of overhead.

8.Explain about Knapps Classification?


KNAPP’S CLASSIFICATION OF DISTRIBUTED DEADLOCK DETECTION ALGORITHMS
The four classes of distributed deadlock detection algorithm are:
1. Path-pushing
2. Edge-chasing
3. Diffusion computation
4. Global state detection
Path Pushing algorithms
• In path pushing algorithm, the distributed deadlock detection are detected by maintaining an
explicit global wait for graph.
• The basic idea is to build a global WFG (Wait For Graph) for each site of the distributed system.
• At each site whenever deadlock computation is performed, it sends its local WFG to all the
neighbouring sites.
• After the local data structure of each site is updated, this updated WFG is then passed along to
other sites, and the procedure is repeated until some site has a sufficiently complete
picture of the global state to announce deadlock or to establish that no deadlocks are
present.
• This feature of sending around the paths of global WFGhas led to the term pathpushing
algorithms.
Examples :Menasce-Muntz , Gligor and Shattuck, Ho and Ramamoorthy, Obermarck
Edge Chasing Algorithms
• The presence of a cycle in a distributed graph structure is be verified by propagating special
messages called probes, along the edges of the graph.
• These probe messages are different than the request and reply messages.
• The formation of cycle can be deleted by a site if it receives the matching probe sent by it
previously.
• Whenever a process that is executing receives a probe message, it discards this message and
continues.
• Only blocked processes propagate probe messages along their outgoing edges.
• Main advantage of edge-chasing algorithms is that probes are fixed size messages which is
normally very short. Examples:Chandy et al., Choudhary et al., Kshemkalyani–Singhal, Sinha–
Natarajan algorithm.

Diffusing Computation Based Algorithms


• In diffusion computation based distributed deadlock detection algorithms, deadlock detection
computation is diffused through the WFG of the system.
• These algorithms make use of echo algorithms to detect deadlocks.
• This computation is superimposed on the underlying distributed computation.
• If this computation terminates, the initiator declares a deadlock.
• To detect a deadlock, a process sends out query messages along all the outgoing edges in the
WFG.
• These queries are successively propagated (i.e., diffused) through the edges of the WFG.
• When a blocked process receives first query message for a particular deadlock detection
initiation, it does not send a reply message until it has received a reply message for every query it
sent.
For all subsequent queries for this deadlock detection initiation, it immediately sends back a reply
message.
• The initiator of a deadlock detection detects a deadlock when it receives reply for every query it
had sent out. Examples:Chandy–Misra–Haas algorithm for one OR model, Chandy–Herman
algorithm.
Global state detection-based algorithms
Global state detection based deadlock detection algorithms exploit the following facts:
1. A consistent snapshot of a distributed system can be obtained without freezing the underlying
computation.
2. If a stable property holds in the system before the snapshot collection is initiated, this property
will still hold in the snapshot. Therefore, distributed deadlocks can be detected by taking a
snapshot of the system and examining it for the condition of a deadlock.

You might also like