Avoidance rules
Avoidance Rules for Deadlocks A deadlock is a situation where multiple processes are waiting for resources held by each other, creating a circular dependency...
Avoidance Rules for Deadlocks A deadlock is a situation where multiple processes are waiting for resources held by each other, creating a circular dependency...
A deadlock is a situation where multiple processes are waiting for resources held by each other, creating a circular dependency that prevents progress. To prevent this, operating systems implement avoidance rules that dictate when processes can acquire resources.
Rule 1: No wait, no share
This rule prohibits a process from waiting for a resource if another process holds the same resource. This ensures resources are not held for extended periods, preventing deadlocks from forming.
Rule 2: No hold, no wait
This rule applies to resources held by a process. A process cannot hold a resource it doesn't need, and cannot wait for another process to release a resource it doesn't require.
Rule 3: Mutual exclusion
This rule states that resources can be acquired in a specific order only. A process cannot acquire a resource if it would leave it holding a conflicting resource.
Rule 4: Priority inversion
In some systems, resources are assigned a priority. Processes acquire resources based on their priority, ensuring critical resources are allocated to processes that need them most.
Additional Avoidance Rules:
Resource ordering: Some systems may enforce specific ordering of resource acquisition. For example, a process may acquire a resource only after it has finished processing a previous resource.
Bounded waiting: In some cases, systems may implement bounded waiting, where processes are allowed to wait for resources for a limited amount of time.
Deadlock detection: Operating systems periodically monitor the system for deadlocks and take corrective actions such as restarting processes or reducing resource allocation.
By adhering to these avoidance rules, operating systems effectively prevent deadlocks from occurring, ensuring smooth system operation and optimal resource utilization