Conditions for deadlocks and how to handle deadlock problems
Solution: Mutex condition (Mutual exclusion):
- 1, resources can not be shared, can only be used by a process.
- 2. Request and maintain conditions (hold and wait): a process that has already received resources can request new resources again.
- 3. Non-deprivation conditions (no pre-emption): The allocated resources cannot be forcibly deprived from the corresponding process.
- 4. Cyclic wait condition (Circular wait): Several processes in the system make up loops in which each process waits for resources that are being consumed by neighboring processes.
How to handle deadlock problems:
- 1. Ignore the problem. For example, the ostrich algorithm, the algorithm can be applied in the case of very few deadlocks occur. Why is called the ostrich algorithm, because the legend of the ostrich saw the danger of burying his head under the ground, perhaps the ostrich feel that there is no danger to see it. It's kind of like deceiving.
- 2. Detect the deadlock and recover.
- 3, carefully dynamic allocation of resources to avoid deadlocks.
- 4, by breaking the deadlock four one of the necessary conditions to prevent the deadlock.
Conditions for deadlocks and how to handle deadlock problems