0% found this document useful (0 votes)
16 views15 pages

Distributed System CSC-503 Distributed Deadlock Handling: Indian Institute of Technology Roorkee

Ds Mutual exclusion

Uploaded by

fakemyself81
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)
16 views15 pages

Distributed System CSC-503 Distributed Deadlock Handling: Indian Institute of Technology Roorkee

Ds Mutual exclusion

Uploaded by

fakemyself81
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/ 15

9/18/2024

INDIAN INSTITUTE OF TECHNOLOGY ROORKEE

Distributed System
CSC-503
Distributed Deadlock Handling

Marks (1.5 + 1.5) x 3

State True or False and give justification

(a)In a system with N processes, the Chandy-Lamport Global State


recording algorithm will always show that at least (N-1)
channels are empty. TRUE

(b) Raymond’s tree-based algorithm requires FIFO channels.


FALSE

(C) When TCP uses SO_LINGER option and l_onoff and l_linger
both are nonzero then TCP always ensures that if any data is still
remaining in TCP send buffer, then all data is sent and
acknowledged by the peer process. FALSE

1
9/18/2024

Consider two clocks that drift 1 second in every 106 seconds with
respect to each other. What is the resynchronization interval
sufficient to limit their skew to 20 milliseconds?

Resynchronization interval = 106 x 20 x 10-3


= 2.12 sec

1 2 5

3 4 5

1 6

Marks: -0.5 for each incorrect value

2
9/18/2024

100 200

210 220 230

001 232

Marks: -0.5 for each incorrect value

(a, e); (b, e); (c, e); (d, e); (f, e)

Marks: 0.5 x 4 for first four; 1 for fifth


-0.5 for wrong pairs

3
9/18/2024

1-abcdh, 2-abcdeh, 3-abcdhf, 4-abcdefh, 5-abcdefgh

Marks: 0.5 x 4 for first four; 1 for fifth


-0.5 for wrong pairs

1 2 5

3 4 5

1 6

It is not a total order as d has happened before h but in this


order d is after h (Marks: 1.5 + 1.5)

4
9/18/2024

Assume Fig. 2 shows an execution of the Ricart-Agrawala algorithm.


When site S3 is in critical section sites S1, S2 and S4 broadcast their
request to enter in critical section. Assume request from S1 is of
highest priority and request from S4 is of lowest priority. What will
be the contents of request deferred array RD at each site after the
site has received all requests? Justify.

3, 1

1,2

6, 3

S1 - 0 0 1
S2 1 - 0 1
S3 1 1 - 1
S4 0 0 0 -

3, 1

1,2

6, 3

5
9/18/2024

S1 - 0 0 1
S2 0 - 0 1
S3 1 1 - 1
S4 0 0 0 -

3, 1

1,2

6, 3

Marks: 5 (if nay of these two); 2.5 to 4 if RD is other than these


two; 0 to 2 otherwise

Assume that a message delivered from site 𝑆𝑖 to site 𝑆𝑗 is 𝑚𝑖𝑗.


Birman-Schiper- Stepheson (BSS) protocol is used for delivering
messages. Fig. 2 shows when a site (not application) implementing
BSS receives the message. Which message will be delivered to the
application immediately by the site and which one will be delayed.
When the delayed messages will be delivered? Assume that initially
all clocks are (0,0,0) and clock is updated when the message is
delivered to the application. For each 𝑚𝑖𝑗 write the clock values
when the message 𝑚𝑖𝑗 is delivered to the application running on site
𝑆𝑗.
1100

0100

1101

6
9/18/2024

Marks: (1+1) x 3 delayed messages; -0.5 for each wrong time


(max 4)

m13, m14 and m43 will be delayed


m24: 0100
m14: 1100

0100 1100 1101


1100 1101
0100 0100 1100 1101

1101

Q8. Worst case quorum size: 8 --- 1 Marks

When node 1, 2, 3, 4, 5, 6, 7 are down ---- 3 Marks


(8, 9, 10, 11, 12, 13, 14, 15)

When node 1, 2, 3, 6, 7 are down -----2 Marks


(4, 8, 5, 10, 12, 13, 14, 15)

Q7 Marks: 2.5 + 2.5 + 5


X: FIN_WAIT_2
Y: CLOSE_WAIT

Server child will not terminate connection as reference count of


descriptor connfd is not zero

7
9/18/2024

Deadlock

• A deadlock occurs when a set of processes in a


system is blocked waiting on requirements that can
never be satisfied
• Theses processes, while holding some resources, are
requesting access to resources held by the other
processes in the same set.
• Processes are involved in a circular wait / ?.

Fundamental causes of Deadlocks

• Exclusive access
• Wait while hold
• No preemption
• Circular wait

A system is prone to deadlock only if it satisfies all of the


above conditions

Deadlock vs. Starvation

8
9/18/2024

Distributed Deadlock Detection


Resource vs. Communication Deadlocks

P1 P2 P3
Receive m3 p3 receive m1 p1 receive m2 p2
send m1 p2 send m2 p3 send m3 p1

Distributed Deadlock Detection


The System Model
• The systems have only reusable resources
• Processes are allowed only exclusive access to resources
• There is only one copy of each resource

A process can be in two states


• Running (ready or running)
• Blocked

9
9/18/2024

A Graph-Theoretic Model

• State of process-resource interaction is modeled by


a bi-partite graph called a resource allocation graph
• Nodes of the graph are processes (generally
represented by circles) and resources (generally
represented by rectangles) of a system
• Edges of the graph (request edge & assignment
edge) depict assignments or pending requests
• The system is deadlocked if its resource allocation
graph contains a directed cycle or a knot

A Knot K in a graph is a nonempty set of nodes such


that for every node x in K, all nodes in K and only the
nodes in K are reachable from x.

Knot: subset of the graph such that starting from any


node in the subset, it is impossible to leave knot

10
9/18/2024

Wait-For-Graph (WFG): Nodes are processes and an edge


from P1 to P2 implies P1 is waiting for a resource from P2.
Resource Allocation Graph WFG

P1 P2

P4 P3

A system is deadlocked iff there is a directed cycle or knot

Handling of deadlocks in distributed systems becomes


highly complicated because no site has accurate
knowledge of the current state of the system

11
9/18/2024

Deadlock Handling Strategies


• Deadlock Prevention
Impractical in dist. systems
• Deadlock Avoidance

• Deadlock Detection:

– Once a cycle is formed in the WFG, it persists until it


is detected and broken

– Cycle detection should proceed concurrently with


normal activities

– Best approach to handle deadlocks in DS

Deadlock Handling Strategies

• Deadlock Detection:
– Maintenance of WFG
– Searching WFG for cycle / knot

• Correctness Criteria:
(i) Progress (No undetected deadlocks)
All deadlocks must be detected in finite time
(ii) Safety (No false deadlocks)

12
9/18/2024

Models of Deadlocks
Request Models: Type of requests
• Only one resource at a time
• Many resources at a time
• Few of many resources at any time

Models of Deadlocks
The Single Unit Request Model
• A process can have at most one outstanding request
for only one unit of a resource.
• 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 (provided that there is only one
unit of every resource in the system)

13
9/18/2024

The AND Request Model


• A process can request for more than one resource
simultaneously
• Process remains blocked until all the requested
resources are granted to the process.
• The out degree of a node in the WFG can be more
than 1.
• The presence of a cycle in the WFG indicates a
deadlock in the AND model (provided that there is
only one unit of every resource in the system)
• A cycle in AND model implies a deadlock but not
vice-versa. A process may not be part of the cycle
but it may still be deadlocked.

The OR Model
• In the OR model, a process can make a request for
numerous resources simultaneously
• Process remains blocked until it is granted any one of
the requested resources.
• Presence of a cycle in the WFG does not imply a
deadlock
• In the OR model, the presence of a knot indicates a
deadlock
• A process not in the knot may also be deadlocked.

14
9/18/2024

Deadlock in a distributed system

15

You might also like