Skip to content

Deadlock Avoidance

Deadlock prevention and avoidance strategies

Method Description Advantages Disadvantages
Deadlock prevention Static strategy, by pre-restricting the resource application of the process to reduce the possibility of deadlock. Simple and intuitive, ensuring that deadlock is avoided from the beginning. Poor flexibility may lead to reduced resource utilization and even resource waste.
Deadlock avoidance Dynamic strategy, allowing processes to dynamically apply for resources, but performing security checks before allocation to prevent the system from entering an unsafe state. Flexible, dynamic resource allocation can avoid deadlock. The analysis and calculation of resource application is complex, the system overhead is large, and it is difficult to accurately grasp the maximum number of resources required by each process.

Deadlock avoidance strategies and methods

Strategy Method Working principle
Banker's algorithm Deadlock avoidance algorithm, used to determine whether the system is still in a safe state after allocating resources. Before allocating resources each time, the system checks whether there are enough resources to meet the current request; if the system is still safe after allocating the resource, the allocation is allowed, otherwise the request is rejected.
Safety check when requesting resources Checks are performed when dynamically allocating resources to ensure that an unsafe state is not entered. The system checks whether the resource request of the process will cause a deadlock, and if it is safe, the request is allowed, otherwise it is rejected.