Question - What is a deadlock in OS? What are the necessary conditions for a deadlock?
Answer -
Deadlock is generally a situation where a set of processes are blocked as each process is holding resources and waits to acquire resources held by another process. In this situation, two or more processes simply try to execute simultaneously and wait for each to finish their execution because they are dependent on each other. We can see a hand problem in our system whenever a deadlock occurs in a program. It is one of the common problems you can see in multiprocessing.
Necessary Conditions for Deadlock
There are basically four necessary conditions for deadlock as given below:
- Mutual Exclusion
- Hold and Wait
- No Pre-emption
- Circular Wait or Resource Wait