A Deadlock is a situation where each of the computer process waits for a resource which is being assigned to some another process. In this situation, none of the process gets executed since the resource it needs, is held by some other process which is also waiting for some other resource to be released. A deadlock may be thought of as indefinite starvation. In the below example, P1 requires resource R1 which is held by P2, but P2 requires resource R1 which is held by P1. This causes both processes to wait indefinitely.
The four conditions mentioned below must all be followed simultaneously to achieve deadlock:
The following strategies are used for handling deadlocks:
Banker's algorithm is one such deadlock avoidance algorithm
Learn about Banker's AlgorithmThis prevents a single thread from entering the same lock more than once.