Repository navigation
circular wait
At the beginning, all resources are available and unallocated. Each process is either in the "running" state, "waiting" state, or "completed" state.
When a process requests a resource, the system checks if the requested resources are available. If the requested resources are available, they are allocated to the process, and the system updates the allocation status.
Once a process holds resources, it can request additional resources without releasing the ones it already holds.
When a process finishes using the allocated resources, it releases them. The released resources become available for allocation to other processes.
To eliminate circular wait, the system must ensure that resource requests are made in a way that prevents a circular chain of waiting. One common approach is to impose a total ordering on resources, assigning a unique number (timestamp) to each resource. Processes are allowed to request resources in increasing order of their timestamps, preventing circular chains.
Whenever a process requests a resource, the system checks if the requested resource's timestamp is greater than the timestamp of any resources the process is currently holding. If the requested resource has a lower timestamp than any held resource, the system denies the request to maintain the order.
A process can only release resources in decreasing order of their timestamps. This order ensures that a higher timestamp resource is released before a lower timestamp resource.
The system enforces the rule that a process can only request resources in increasing order of timestamps and release them in decreasing order. This prevents a circular chain of waiting, as processes cannot request resources in a way that forms a cycle.
The process repeats as new resource requests and releases occur.