Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Deadlock in OS

Presentation
What is Deadlock
Deadlock is a state in a computer system where two or
more processes are unable to proceed because each is
waiting for the other to release a resource, such as
memory or a file, or to perform an action.
Examples

Real-life Technical
One real-life example of deadlock is a traffic A classic technical example of
gridlock. Imagine an intersection where four deadlock involves two processes
roads meet, and there are traffic lights competing for two resources, each
controlling the flow of vehicles. If each road holding one resource and waiting
has equal traffic volume and the traffic for the other
lights are not coordinated properly, a
deadlock can occur.
Condition

Hold and Wait Non Preemption

Mutual Exclusion Circular Wait


Resource
Allocation Graph
Deadlock Preventions
Deadlock prevention involves modifying the system to ensure that at least one of the
necessary conditions for deadlock cannot hold. There are several strategies to achieve this:

Mutual Exclusion: Allow resources to be shareable instead of exclusive. If resources can be


used by multiple processes simultaneously, the mutual exclusion condition is eliminated.

Hold and Wait: Require processes to request and acquire all the resources they need at the
start, rather than acquiring them incrementally. This ensures that a process only holds
resources while it is actively executing, reducing the likelihood of deadlock.

No Preemption: Allow resources to be preempted if necessary. If a process holding resources


is waiting for additional resources that are held by other processes, those resources can be
preempted and allocated to the waiting process, breaking the potential deadlock.

Circular Wait: Impose a total ordering of resource types and require that each process
requests resources in an increasing order of enumeration. This way, circular waits are
prevented because processes can only request resources that are of a lower priority than the
ones they currently hold.
Strategies for
handling deadlock
prevention Avoidance Resource
Preemption
Modify the system to Use algorithms that Temporarily take resources away
dynamically analyze the from some processes and give them
prevent at least one of the
to others to break the circular wait
necessary conditions for state of the system to condition.
deadlock (mutual ensure that deadlock will Requires careful implementation to
exclusion, hold and wait, not occur. avoid race conditions and ensure
fairness.
no preemption, circular
wait) from occurring.
Thank You !

You might also like