A DeadLock is the situation where a two programs are sharing the same resources and both of them are waiting for each other to release that resource, bit it never occurs.

When a thread in an operating system requests a resource, which is held by another thread in waiting state, this thread also will eventually enter in a waiting state. This means both threads are are waiting for them to release the resources, thus a deadlock situation occurs. It creates a kind of a cycle where none of the programs can continue.

DeadLock

Previously, operating system used to be single task, this means only one program could be executed at a time and it could gain access to all the resources required for its operation and since no other program is using those resources, it avoids the deadlock situation. But now these days, operating system can execute multiple programs at a time, and to make matters worst, some operating system provide the facility to choose the resource dynamically after the program has been executed. This increments the chances of a deadlock.

DeadLock can be prevented using various handling methods.