Four Conditions for deadlock:
(1) mutex condition: A resource can only be used by one process at a time.
(2) request and retention conditions: when a process is blocked by requesting resources, it will not release the obtained resources.
(3) Non-deprivation condition: the resources obtained by the process cannot be forcibly deprived before they are used.
(4) Cyclic waiting condition: a cyclic waiting resource relationship is formed between several processes that are connected at the beginning and end.
These four conditions are necessary for a deadlock. As long as a deadlock occurs in the system, these conditions must be met. As long as one of the above conditions is not met, no deadlock will occur.
Deadlock elimination method:
1. Undo All deadlocked processes;
2. Undo the deadlocked process one by one until the deadlock does not exist;
3. Force the resources used one by one from the deadlocked process until the deadlock disappears.
4. Forcibly deprive other processes of sufficient resources and allocate them to the deadlock process to relieve the deadlock.
References: http://baike.baidu.com/view/121723.htm
Reference: http://zhidao.baidu.com/question/65925327