A possible method for preventing deadlocks is to have a single, higherorder reso
ID: 3605145 • Letter: A
Question
A possible method for preventing deadlocks is to have a single, higherorder resource that must
be requested before any other resource. For example, if multiple threads attempt to access the
synchronization objects A··· E, deadlock is possible. (Such synchronization objects may include
mutexes, semaphores, condition variables, and the like.) We can prevent the deadlock by adding
a sixth object F. Whenever a thread wants to acquire the synchronization lock for any object
A··· E, it must first acquire the lock for object F. This solution is known as containment: the locks
for objects A ··· E are contained within the lock for object F.
Compare this scheme with the
circular-wait scheme, which is defined as: there exists a set {P0 , P1 , …, Pn } of waiting processes such that P0 is waiting for a resource that is held by P1 , P1 is waiting for a resource that is held by P2 , …, Pn–1 is waiting for a resource that is held by Pn , and Pn is waiting for a resource that is held by P0 .
Explanation / Answer
The thumb rule is that the scope of locking scheme should be as narrower as possible ,because if the scope is larger it will block more resources and it will reduce CPU utilization .
Containment the lock scheme
-------------------------------------------------
In the containment: the locks scheme we are blocking 5 resources by acquiring lock on object F. Obviously it will reduce CPU utilization as at a time only one process will have access to all the resources.it may also happen then that one process may need only one resource at a moment ,but it will forced to lock all the resources to access that single resource .
But it maximizes the no of resources that can be allocated to a single process at a time.
Circular wait scheme
In circular wait scheme the scope is small, at a time a process may block at max any two resources.
So it increases CPU utilization.
But the max no of resource that can be allocated to a process is limited 2.
It has a serious draw back it may lead to indefinite deadlock when P0 is waiting for a resource that is held by P1 , P1 is waiting for a resource that is held by P2 , …, Pn–1 is waiting for a resource that is held by Pn , and Pn is waiting for a resource that is held by P0 .
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.