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

Slidesgo Breaking The Chains Mastering Deadlock Prevention and Avoidance Strategies 20241007172827nQ3E

gives a clear understanding of deaadlocks

Uploaded by

respectkills
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)
11 views

Slidesgo Breaking The Chains Mastering Deadlock Prevention and Avoidance Strategies 20241007172827nQ3E

gives a clear understanding of deaadlocks

Uploaded by

respectkills
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/ 8

Deadlock Prevention

and Avoidance
Strategies
Deadlock Prevention

Deadlock prevention aims to


ensure that at least one of the
four necessary conditions for a
deadlock (mutual exclusion, hold
and wait, no preemption, and
circular wait) does not occur. This
is typically done by using the
following strategies:
1. Mutual Exclusion: This condition is unavoidable for non-shareable
resources. But if resources can be made shareable, deadlocks can be
prevented.

2. Hold and Wait: Processes should not hold onto resources while waiting
for others. This can be prevented by:

Requiring processes to request all required resources at once.

Ensuring a process releases all held resources before requesting more.


3. No Preemption: Allowing
preemption of resources can prevent
deadlock. This means if a process
holding some resources requests
another resource that is not
immediately available, all held
resources are released.

4. Circular Wait: Imposing an order on


resource acquisition can break circular
wait. Each process must request
resources in a predefined order,
ensurno circular chain of processes.
Deadlock Avoidance

Deadlock avoidance requires additional


information about processes and their
future resource requests. It dynamically
checks whether granting a resource
request will keep the system in a safe
state (where no deadlock can occur). The
most famous algorithm for deadlock
avoidance is the Banker’s Algorithm,
which works as follows:
1. Processes must declare maximum
resource needs in advance

2. The system checks if resource


allocation would lead to a safe state,
meaning there is a sequence of resource
allocations that ensures all processes can
complete without causing a deadlock.

3. If the system cannot ensure this, the


request is denied to avoid a potential
deadlock.
Key Difference:

Prevention: Tries to structurally


eliminate the possibility of
deadlock by breaking one of the
necessary conditions.

Avoidance: Dynamically checks


each resource request to ensure it
won't lead to a deadlock.
Any doubts?

Thank you

You might also like