SUMMARY
- A deadlocked state occurs when two or more processes are waiting indefinitely for an event that can be caused by only one of the waiting processes.
- Three methods for dealing with the deadlock
- Use some protocol to prevent or avoid deadlock, ensuring that the system never enters deadlocked state
- Allow the system to enter a deadlocked state, detect it and then recover
- Ignore the problems altogether and pretend that deadlocks never occur in the system
- The third one is the most used
- The four necessary conditions for deadlock are mutual exclusion, hold and wait, no preemption, circular wait
- To prevent deadlock ensure that atleast one of the necessary conditions never holds
- To avoid deadlock, the OS must have the prior information of how each process will utilize system resources.
- A deadlock detection algorithm must be invoked to determine whether deadlock has occurred
- If a deadlock is detected, the system must recover either by terminating some of the deadlocked process or by preempting resources from some of the deadlocked processes
- Where preemption is used to deal with deadlocks, three issues must be addressed: selecting a victim, rollback, starvation