Avoidance
Avoidance: A Technique for Preventing Deadlocks A deadlock is a situation where multiple processes are waiting for resources held by each other, creating an...
Avoidance: A Technique for Preventing Deadlocks A deadlock is a situation where multiple processes are waiting for resources held by each other, creating an...
A deadlock is a situation where multiple processes are waiting for resources held by each other, creating an indefinite cycle of waiting and deadlock. To avoid this, the operating system employs various techniques, including avoidance.
Avoiding starvation: This technique aims to prevent one process from indefinitely waiting for resources held by another process. For example, imagine two processes, A and B, each needing resource X. Process A requests resource X from B, while B requests resource Y from A. Both processes are waiting for resources held by each other, creating a deadlock. By implementing avoidance, A and B can negotiate and agree on a different resource allocation that avoids deadlock.
Avoiding livelock: A livelock is a deadlock where two or more processes are stuck in a cycle of waiting for each other's resources, leading to a slow system performance. Avoidance techniques, such as priority scheduling and resource allocation, help prevent livelocks from occurring.
Avoiding circular waits: Circular waits occur when two processes are waiting for resources held by each other, creating a loop of waiting. Avoidance techniques work by ensuring that resources are distributed in a cyclic fashion, preventing processes from getting stuck in a circular wait.
Examples:
Resource allocation: In a multi-threaded system, threads requesting different resources need to avoid waiting for each other's allocation.
Priority scheduling: Processes with higher priority are allowed to get resources before those with lower priority. This helps prevent starvation and livelocks.
Lock ordering: In multi-process systems, processes acquire locks in a specific order, ensuring that resources are distributed appropriately.
By employing these avoidance techniques, operating systems ensure smooth system operation and prevent deadlocks from occurring