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

Deadlock Prevention Strategies Explained

The document discusses checkpoint-based recovery in distributed computing, where processes save their state periodically to stable storage to minimize lost computation during failures. It explains the types of checkpointing, including uncoordinated, coordinated, and communication-induced checkpointing, detailing how each method manages checkpoints to avoid issues like the domino effect. Additionally, it provides an example of the Juan-Venkatesan algorithm illustrating how processors handle rollbacks and maintain consistent states during recovery.
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)
9 views15 pages

Deadlock Prevention Strategies Explained

The document discusses checkpoint-based recovery in distributed computing, where processes save their state periodically to stable storage to minimize lost computation during failures. It explains the types of checkpointing, including uncoordinated, coordinated, and communication-induced checkpointing, detailing how each method manages checkpoints to avoid issues like the domino effect. Additionally, it provides an example of the Juan-Venkatesan algorithm illustrating how processors handle rollbacks and maintain consistent states during recovery.
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 said:

DeadLock handling strategies : Deadlock Prevention

ChatGPT said:

Here is a clear, exam-ready 16-mark answer on Deadlock Prevention under Deadlock


Handling Strategies.

Deadlock Handling Strategies: Deadlock Prevention (16 Marks)

Deadlock prevention is a strategy used in operating systems to ensure that at least one of
the four necessary conditions for deadlock never occurs. By structurally restricting resource
requests, the system guarantees that deadlocks cannot form. Although it may reduce
resource utilization, it provides a safe and predictable environment.

Introduction

A deadlock occurs when a set of processes is permanently blocked because each process is
holding one resource and waiting for another. The four necessary conditions for deadlock
are:

1. Mutual Exclusion

2. Hold and Wait

3. No Pre-emption

4. Circular Wait

Deadlock prevention works by breaking one or more of these conditions so that deadlock
becomes impossible.

1. Preventing Mutual Exclusion

• Mutual exclusion means some resources can be used by only one process at a time.

• In prevention, OS tries to make resources sharable wherever possible.

• Example: read-only files, shared memory.

• But certain resources (printers, I/O devices) cannot be shared, so complete


prevention is not always practical.
Advantage: Reduces chances of deadlock.
Disadvantage: Only applicable to sharable resources.

2. Preventing Hold and Wait

This is done by ensuring a process does not hold one resource while waiting for another.

Methods:

• A process must request all required resources at once before execution starts.

• Or, a process can request resources only when it holds none.

Pros:

• Eliminates hold-and-wait condition completely.

Cons:

• Leads to low resource utilization (resources stay idle).

• Increases process starvation because large requests delay others.

3. Preventing No Pre-emption

Allows the operating system to forcibly take back resources from a process.

Rules:

• If a process holding some resources requests another resource that is not available,
→ all resources currently held are pre-empted.

• These pre-empted resources are added back to the pool.

• Process is restarted later when all resources are available.

Advantage:

• Effective for CPU registers, memory.

Disadvantage:

• Cannot be used for non-preemptible resources (printer output, I/O).

4. Preventing Circular Wait

This is one of the most widely used prevention techniques.

Technique: Resource Ordering


• All resources are assigned a unique numbering or hierarchy.

• A process must request resources in increasing order of numbering only.

Example:

If Printer = R1, Scanner = R2, Disk = R3


A process must request in the order R1 → R2 → R3.

Benefit:

• Ensures no circular chain can form.

• Simple to implement.

Drawback:

• Not flexible for processes with dynamic resource needs.

Advantages of Deadlock Prevention

• Ensures deadlocks will never occur.

• System behaviour becomes predictable and safe.

• Suitable for real-time systems where uninterrupted execution is critical.

Disadvantages

• May cause poor resource utilization.

• Processes may be forced to wait long, causing starvation.

• Limits how processes request resources → reduces concurrency.

Conclusion

Deadlock prevention is a proactive strategy that ensures the system never enters a deadlock
state by breaking one of the four required conditions. Although it guarantees safety, it
imposes rigid constraints on resource allocation and may reduce system efficiency. Still, it is
widely used when reliability is more important than performance.

If you want, I can also give Deadlock Avoidance, Detection & Recovery, or a combined 16-
mark full answer for Deadlock Handling Strategies.
You said:

deadlock avoidance

ChatGPT said:

Here is a perfect, neat 16-mark exam answer for Deadlock Avoidance under Deadlock
Handling Strategies.

Deadlock Handling Strategies: Deadlock Avoidance (16 Marks)

Deadlock avoidance is a dynamic strategy used by operating systems to ensure the


system never enters an unsafe state that could lead to a deadlock. Unlike prevention,
avoidance does not restrict resource usage heavily; instead, it makes resource allocation
decisions carefully by analyzing the current and future needs of processes.

Introduction

A deadlock occurs when processes are stuck permanently, each waiting for others.
Deadlock avoidance works on the principle that OS should not grant a resource request if it
leads the system into an unsafe state.

An unsafe state does not guarantee deadlock, but deadlock may occur.
A safe state ensures that there exists at least one sequence in which all processes can
complete.

Key Idea of Deadlock Avoidance

The system:

1. Examines each resource request.

2. Predicts whether granting it keeps the system in a safe state.

3. Grants the resource only if it is safe.

This requires OS to have complete knowledge of maximum resource requirements of each


process.

Safe State

A system is in a safe state if the OS can find a sequence of processes (safe sequence) in
which:
• Each process can get required resources,

• Complete execution,

• And release resources for the next process.

If no such sequence exists → unsafe state → possible deadlock.

Deadlock Avoidance Methods

1. Banker's Algorithm

The most famous deadlock avoidance algorithm.

Used For:

• Multiple instances of each resource type.

• Systems where processes declare maximum resource requirement in advance.

Data Structures:

• Max Matrix – maximum number of resources a process may request

• Allocation Matrix – current allocated resources

• Need Matrix = Max – Allocation

• Available Vector – free resources

Working:

When a process requests resources:

1. Temporarily allocate the resource.

2. Check if system remains in a safe state.

3. If safe → grant the request.

4. If unsafe → deny and make process wait.

Advantages:

• Prevents deadlock efficiently.

• Allows more concurrency than Prevention.

Disadvantages:

• Requires prior knowledge of maximum resource demand.

• High overhead in large systems.


2. Resource Allocation Graph (RAG) Algorithm

Used when:

• There is only one instance for each resource type.

Modification for Avoidance:

Introduce "claim edges" that show possible future requests.

Steps:

1. Each process declares all possible resources it might request.

2. Before granting a request, OS checks if converting a claim edge to request edge


creates a cycle.

3. If cycle forms → request denied → leads to unsafe state.

4. If no cycle → safe → grant resource.

Characteristics of Deadlock Avoidance

• Requires advance knowledge of resource requirements.

• Decisions are made at runtime (dynamic checking).

• Avoids deadlocks by ensuring safe state always.

• Utilizes resources more efficiently than deadlock prevention.

Advantages

• Better resource utilization compared to prevention.

• Allows processes to request resources dynamically (flexible).

• Guarantees system remains deadlock-free.

Disadvantages

• Needs complete information about future requests (difficult in modern systems).

• Overhead of checking safe state for every request.

• Not suitable for large-scale or unpredictable environments.


Conclusion

Deadlock avoidance is a proactive and flexible technique that ensures the system never
enters a potential deadlock state by checking safety before allocating resources. Algorithms
like the Banker’s Algorithm and Resource Allocation Graph help maintain a safe sequence of
execution. Although it incurs runtime overhead, deadlock avoidance provides an effective
balance between system safety and resource utilization.

If you want, I can also give Deadlock Detection & Recovery (16 marks) or a combined 16 /
20-mark answer for all deadlock handling strategies.

You said:

CS3551_-_Distributed_Computing[1].pdf

PDF

from this pdf ciopy and paste here only checkpoint based recvery topic

ChatGPT said:

Here is the exact content from the PDF for the topic “Checkpoint Based Recovery” (copied
exactly from the file, with citations).

Checkpoint Based Recovery

A process periodically saves its state (a checkpoint) to stable storage.


If a failure occurs, the process rolls back to the most recent checkpoint instead of restarting
from the beginning.
This reduces the amount of lost computation.

CS3551_-_Distributed_Computing[…

How Checkpointing Works

• A checkpoint is a snapshot of the process state.

• When a failure occurs, the system restores the latest checkpoint.

• The recovery mechanism ensures the process resumes consistent execution.

CS3551_-_Distributed_Computing[…

Types of Checkpointing
1. Uncoordinated Checkpointing

• Processes take checkpoints independently.

• Can lead to domino effect, where several processes must roll back repeatedly.

CS3551_-_Distributed_Computing[…

2. Coordinated Checkpointing

• All processes coordinate to take a consistent global checkpoint.

• Avoids domino effect.

CS3551_-_Distributed_Computing[…

3. Communication-Induced Checkpointing

• Processes take checkpoints based on message patterns to ensure global


consistency.

CS3551_-_Distributed_Computing[…

If you want, I can also extract Message Logging, Rollback Recovery, or Types of
Failures from the same PDF.

Sources

You said:

Model-based checkpointing • Model-based checkpointing prevents patterns of


communications and checkpoints that could result in inconsistent states among the existing
checkpoints. • No control messages are exchanged among the processes during normal
operation. All information necessary to execute the protocol is piggybacked on application
messages • There are several domino-effect-free checkpoint and communication model. •
The MRS (mark, send, and receive) model of Russell avoids the domino effect by ensuring
that within every checkpoint interval all message receiving events precede all message-
sending events. Index-based checkpointing. • Index-based communication-induced
checkpointing assigns monotonically increasing indexes to checkpoints, such that the
checkpoints having the same index at different processes form a consistent state. explain in
thanglish

ChatGPT said:
Here is the explanation of Model-based checkpointing and Index-based
checkpointing in simple Thanglish (easy to write in exam).

Model-based Checkpointing – Thanglish Explanation

Model-based checkpointing nu sollumbothu, system communication pattern ah follow


pannitu checkpoint edukkum. Idhu nala inconsistent state vara ma irukkum.

Main Points (Thanglish-la easy ah):

• Model-based checkpointing communication pattern ah analyse pannum.


Inconsistent checkpoint varadha nu control pannum.

• Normal operation la extra control messages send panna maataanga.


Application messages la thaniya required information piggyback panniduvaanga
(apdiye attach panniduvaanga).

• Ithula pala domino-effect-free models irukku.


(Domino effect = oru process rollback aana, vera process um rollback aaganum —
ithu avoid pannum).

• MRS model (Mark–Receive–Send) of Russell

• Idhu oru important model.

• Ithu sollrathu: oru checkpoint interval kulla, ella receive


events mudinjirukanum send event nadakka munnaadi.

• Ithu nala consistent checkpoint கிடைக்கும் , domino effect avoid aagum.

Index-based Checkpointing – Thanglish Explanation

Index-based checkpointing na checkpoint ku numbers (index) kuduthu manage


pannuvanga.

Main Points (Thanglish-la):

• Oru process checkpoint edukkum podhu, adhu ku oru monotonically increasing


index number kuduppanga.
(Ex: 1, 2, 3… order skip agama pogum.)

• Same index irukkura checkpoint ellam different processes la irundhaalum,


adhu together consistent global state nu consider pannuvanga.

• Ithu oru communication-induced checkpointing method, so checkpoint edukkura


time communication pattern pola irukkum.
Simple summary (Exam ku super useful):

• Model-based checkpointing → Communication pattern follow pannitu inconsistent


checkpoint avoid pannum. Extra control message illai.

• MRS model → Receive events first, send events later → domino effect avoid.

• Index-based checkpointing → Checkpoint ku number assign pannuvanga; same index


irukkura checkpoint ellam consistent state.

If you want, I can also explain Domino effect, Coordinated vs Uncoordinated Checkpointing,
or make this into a 16-mark full answer.

You said:

3. Communication-induced Checkpointing Communication-induced checkpointing is another


way to avoid the domino effect, while allowing processes to take some of their checkpoints
independently. Processes may be forced to take additional checkpoints Two types of
checkpoints 1. Autonomous checkpoints 2. Forced checkpoints The checkpoints that a
process takes independently are called local checkpoints, while those that a process is forced
to take are called forced checkpoints. • Communication-induced check pointing piggybacks
protocol- related information on each application message • The receiver of each application
message uses the piggybacked information to determine if it has to take a forced checkpoint
to advance the global recovery line • The forced checkpoint must be taken before the
application may process the contents of the message • In contrast with coordinated check
pointing, no special coordination messages are exchanged Two types of commu idha
thanglish la explaon pannu

ChatGPT said:

Here is the Communication-Induced Checkpointing explanation in simple Thanglish, exactly


based on your content.
Super clear for exam writing.

Communication-Induced Checkpointing – Thanglish Explanation

Communication-induced checkpointing na, process-la domino effect avoid panna help


pannum.
But same time, process some checkpoints independent-ah edutha kuda allow pannum.

System konjam time-la forced ah checkpoint edukkanum.


So checkpoint types rendu:
Autonomous Checkpoints (Local Checkpoints)

• Process tanakku venumna time-la thaniya edukkura checkpoint.

• Idhu independent-ah eduthathu, yaarum force panna maataanga.

• Idha local checkpoint nu koopduvaanga.

Forced Checkpoints

• Process receive panra application message la piggyback panna information pathi


decide pannum.

• Message vandha udane, system forced checkpoint edukanum nu sonnaa,


→ Process forced checkpoint edukkanum.

• Ithu global recovery line ah correct-ah maintain panna help pannum.

How Communication-Induced Checkpointing Works (Thanglish)

• Application message ellathukkum protocol-related info piggyback panniduvanga


(apdiye message-oda attach panniduvaanga).

• Receiver process message vandha udane piggyback info check pannum.

• “Forced checkpoint venuma?” nu decide pannum.

• Venumna, checkpoint eduthuttu than message process pannum.

• Ithu coordinated checkpointing madhiri extra coordination messages send panna


maataanga.
So overhead kammi.

Simple Summary (Exam-ready Thanglish)

• Communication-induced checkpointing la 2 types:


✔ Autonomous (local)
✔ Forced

• Forced checkpoint message receive aagum bodhu piggyback info base-ah


edukkanum.

• No separate coordination message use panna maataanga.


• Global recovery line correct-ah maintain pannum, domino effect avoid pannum.

If you want, I can also explain Domino Effect, Global Recovery Line, or convert this into a full
8 / 16 mark answer.

You said:

D. An Example Consider an example shown in Figure 2 consisting of three processors.


Suppose processor Y fails and restarts. If event ey2 is the latest checkpointed event at Y, then
Y will restart from the state corresponding to ey2. Figure 2: An example of Juan-Venkatesan
algorithm. • Because of the broadcast nature of ROLLBACK messages, the recovery
algorithm is initiated at processors X and Z. • Initially, X, Y, and Z set CkPtX ← ex3, CkPtY ←
ey2 and CkPtZ ← ez2, respectively, and X, Y, and Z send the following messages during the
first iteration: • Y sends ROLLBACK(Y,2) to X and ROLLBACK(Y,1) to Z; • X sends
ROLLBACK(X,2) to Y and ROLLBACK(X,0) to Z; • Z sends ROLLBACK(Z,0) to X and
ROLLBACK(Z,1) to Y. Since RCVDX←Y (CkPtX) = 3 > 2 (2 is the value received in the
ROLLBACK(Y,2) message from Y), X will set CkPtX to ex2 satisfying RCVDX←Y (ex2) = 1≤ 2.
Since RCVDZ←Y (CkPtZ) = 2 > 1, Z will set CkPtZ to ez1 satisfying RCVDZ←Y (ez1) = 1 ≤ 1. At Y,
RCVDY←X(CkPtY ) = 1 < 2 and RCVDY←Z(CkPtY ) = 1 = SENTZ←Y (CkPtZ). Y need not roll back
further. In the second iteration, Y sends ROLLBACK(Y,2) to X and ROLLBACK(Y,1) to Z; Z sends
ROLLBACK(Z,1) to Y and ROLLBACK(Z,0) to X; X sends ROLLBACK(X,0) to Z and ROLLBACK(X, 1)
to Y. If Y rolls back beyond ey3 and loses the message from X that caused ey3, X can resend
this message to Y because ex2 is logged at X and this message available in the log. The
second and third iteration will progress in the same manner. The set of recovery points
chosen at the end of the first iteration, {ex2, ey2, ez1}, is consistent, and no further rollback
occurs. explain in thanglish

ChatGPT said:

Here is the Juan–Venkatesan rollback recovery example explained in super-clear Thanglish,


exactly matching your PDF content.

D. Example – Thanglish Explanation

Figure 2-la three processors irukku: X, Y, Z.


Ipdi oru situation imagine pannunga:

Step 1: Processor Y fail aagudhu

• Y crash aagi restart aagum.

• Y-kku last checkpointed state ey2.


• So Y ey2-la irundhu thirumba start pannum.

Rollback Messages Start (First Iteration)

Because rollback message broadcast ah send pannuvanga,


X um Z um recovery process start pannuvanga.

First iteration-la initial checkpoint values:

• CkPtX = ex3

• CkPtY = ey2

• CkPtZ = ez2

Messages sent in 1st iteration:

✔ Y sends

• ROLLBACK(Y,2) → X

• ROLLBACK(Y,1) → Z

✔ X sends

• ROLLBACK(X,2) → Y

• ROLLBACK(X,0) → Z

✔ Z sends

• ROLLBACK(Z,0) → X

• ROLLBACK(Z,1) → Y

Processor X Reaction

Y-kitta irundhu ROLLBACK(Y,2) message vandhudhu.


So X check pannum:

• RCVD_X←Y(CkPtX) = 3

• Received rollback value = 2

3 > 2 → too advanced checkpoint.

So X rollback to ex2,
because ex2 satisfies: RCVD value = 1 ≤ 2.
Processor Z Reaction

Y-oda rollback message value = 1


Check:

• RCVD_Z←Y(CkPtZ) = 2

• Received value = 1

2 > 1 → rollback needed.

Z rollback to ez1
because RCVD(ez1) = 1 ≤ 1.

Processor Y Reaction

Y check pannum:

• RCVD_Y←X(ey2) = 1 < 2

• RCVD_Y←Z(ey2) = 1 = SENT_Z←Y(CkPtZ)

So Y-ku rollback thevai illa.


Y stays at ey2.

Second Iteration

2nd iteration-la same madhiri messages send pannuvanga:

✔ Y sends

• ROLLBACK(Y,2) → X

• ROLLBACK(Y,1) → Z

✔ Z sends

• ROLLBACK(Z,1) → Y

• ROLLBACK(Z,0) → X

✔ X sends

• ROLLBACK(X,0) → Z

• ROLLBACK(X,1) → Y
Rollback values match aagara reason system consistent state reach pannum.

Why No Further Rollback Occurs

If Y rollback aagi ey3 message lose aagiduchuna,


X ex2 checkpoint log-la irukkaradhunaala
→ X can resend the lost message to Y.

So 2nd and 3rd iteration same effect thaan.

Final Consistent Set

At the end of the first iteration itself,


the stable consistent recovery points are:

{ ex2, ey2, ez1 }

This set is globally consistent,


so innum rollback thevai illa.

You might also like