Skip to content

Latest commit

 

History

History
13 lines (7 loc) · 1.36 KB

File metadata and controls

13 lines (7 loc) · 1.36 KB

Deadlock is a situation in a multi-process system where two or more processes are blocked and waiting for each other to release resources, causing a standstill or a deadlock. In other words, deadlock is a state where two or more processes are blocked indefinitely and can't proceed further because each is waiting for a resource that only the other can release.

There are four necessary conditions for deadlock to occur:

1.Mutual Exclusion: At least one resource must be held in a non-sharable mode. This means that only one process can use the resource at a time.

2.Hold and Wait: A process must be holding at least one resource and waiting to acquire additional resources held by other processes.

3.No Preemption: Resources cannot be preempted or taken away from a process unless the process voluntarily releases them.

4.Circular Wait: A set of processes must be waiting for each other in a circular chain-like structure. For example, process P1 is waiting for a resource held by process P2, which in turn is waiting for a resource held by process P3, and so on, until process PN is waiting for a resource held by process P1.

If all of these conditions hold true simultaneously, then a deadlock can occur. It's important to note that if any one of these conditions is not met, then deadlock cannot occur. Therefore, to prevent deadlock, we need to break at least one of these conditions.