首页 > 试题广场 >

A possible solution for preven

[问答题]
A possible solution 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, etc.) 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.
推荐
This is probably not a good solution because it yields too large a scope. It is better to define a locking policy with as narrow a scope as possible.
发表于 2018-03-18 22:21:51 回复(0)