0% found this document useful (0 votes)
11 views7 pages

Deadlock Prevention

deadlock prevention

Uploaded by

pkhangel7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODP, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views7 pages

Deadlock Prevention

deadlock prevention

Uploaded by

pkhangel7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODP, PDF, TXT or read online on Scribd
You are on page 1/ 7

Deadlock prevention

Deadlock: A deadlock is a situation where two or more transactions


are unable to proceed because each is waiting for a resource that is
locked by another transaction. Deadlocks occur in database management
systems (DBMS) when two or more transactions are waiting indefinitely
for each other to release locks.
•if P1 wants R2 to finish its
execution, but P2 is holding onto it,
P1 must wait. Similar to P1, P2
might be anticipating R1, who is
held by P1. P2 must hold off until
P1 releases the resource. As a result,
there is a deadlock scenario,
Deadlock prevention
To ensure that system will never enter a deadlock status
Deadlock can be prevented by eliminating any of the four necessary conditions, which are mutual exclusion, hold and wait, no
preemption, and circular wait. Mutual exclusion, hold and wait and no preemption cannot be
violated practically. Circular wait can be feasibly eliminated by assigning a priority to each resource .

Here are some common strategies to prevent deadlocks:


i. Mutual Exclusion:
ii. Hold and Wait:
iii. No Preemption
iv. Circular Wait

Mutual Exclusion:

• Ensure that resources that can't be shared are only assigned to one
process at a time.(condition must hold for non-sharable resource)
• mutual exclusion means that multiple processes can't use the same
resource at the same time.
• This strategy involves ensuring that resources, such as files, devices,
or data structures, can only be accessed by one process at a time

Hold and Wait:

• A process waits for same resource while welding another resource at the same

time

• Hold and wait condition occurs when a process holds a resource and is also

waiting for some other resource in order to complete its execution. Thus, if

we did not want the occurrence of this condition then we must guarantee

that when a process requests a resource, it does not hold any other resource

No Preemption
• The process which once scheduling will be executed till the completion

• This means that once a process has been allocated resources, it keeps them until it

voluntarily releases them. If a process requests a resource that is currently

allocated to another process, the requesting process must wait until the

resource becomes available.


Circular Wait

• All the processes must be waiting for the resource in a cyclic manner

• In circular wait, two or more processes wait for resources in a circular


order. We can understand this better by the diagram given:

• To eliminate circular wait, we assign a priority to each resource. A


process can only request resources in increasing order of priority.

• consider three processes, P1, P2, and P3, each holding a different
resource R1, R2, and R3, respectively, and waiting for a resource
held by a process with lower priority. If P1 has the highest priority,
P2 has medium priority, and P3 has the lowest priority, the system
can allocate resources in such a way that P3 must release its resource
before P2 can acquire it, and P2 must release its resource before P1
can acquire it.

You might also like