Circular Wait - aryanjoshi0823/5143-Operating-System GitHub Wiki
Circular Wait in Operating Systems
Circular Wait is one of the necessary conditions for a deadlock to occur in a system. It refers to a situation where a group of processes is waiting on each other in a circular chain, such that each process holds at least one resource and is waiting to acquire a resource held by the next process in the chain.
Example:
- Process P1 holds Resource R1 and waits for R_2.
- Process P2 holds Resource R_2 and waits for R_1.
This circular dependency prevents any process from proceeding, leading to a deadlock.
Preventing Circular Wait:
To prevent circular wait and avoid deadlock, one or more of the following strategies can be employed:
-
Impose a Resource Ordering:
- Assign a unique number to each resource type.
- Require processes to request resources in increasing numerical order.
-
Break the Circle:
- Use algorithms that detect and resolve circular dependencies (e.g., Banker's Algorithm).
- Introduce a timeout or resource preemption mechanism.
Circular wait is a critical concept in resource allocation and deadlock management in operating systems.