- A deadlock is a condition when two or more transactions are executing and each transaction waiting for the other to finish but none of them are ever finished. So all the transactions will wait for infinite time and not a single transaction completed.
- In the above Deadlock Conditions figure, there are two transactions 1 and 2 and two table’s as table1 and table 2.
- Transaction 1 hold table 1 and wait for table 2. Transaction 2 hold table 2 and wait for table 1.
- Now table 1 is wanted by transaction 2 and that hold by transaction 1 and same way table 2 wanted by transaction 1 and that is held by transaction 2. Until anyone can’t get this table they can’t proceed further so this called wait for graph. Because both of these transactions have to wait for some resources.
When deadlock occurs
- A Deadlock Conditions occurs when two separate processes struggle for resources held by one another.
- Deadlocks can occur in any concurrent system where processes wait for each other. And a cyclic chain can arise with each process waiting for the next one in the chain.
- Deadlock can occur in any system that satisfies the four conditions:
- Mutual Exclusion Condition: only one process at a time can use a resource or each resource assigned to 1 processor is available.
- Hold and Wait Condition: processes already holding resources may request new resources.
- No Preemption Condition: only a process holding a resource can release it voluntarily after that process has completed its task or previously granted resources cannot forcibly take away from any process.
- Circular Wait Condition: two or more processes forms the circular chain where each process requests a resource that the next process in the chain holds.