First, we detect the deadlock through Resource allocation graph method. if there is no deadlock in the graph then there is no problem. Otherwise we follow, one of the following deadlock recovery method to remove the deadlock.
1. Kill One/All Deadlocked Processes
Kill one process and check deadlock status. If deadlock is removed then the system is deadlock free otherwise kill one more process and so on, continues killing the other processes until the deadlock is removed. In simple words, kill all those processes which are involved in deadlock situation. Definitely it hampers the performance of the system.
2. Preempt Resources
Preempt the resources from those processes which are involved in the deadlock and assign these resources to other processes which are not involved in deadlock. So that, system can be recovered from deadlock. But starvation increase in the system.
3. Roll Back Resource
Roll back the resource until the elimination of deadlock.