|
![](/i/fill.gif) |
Orchid XP v8 <voi### [at] dev null> wrote:
> If you assign a unique ID to every lock in the system, and arrange for
> every thread to take whatever locks it needs to take in ascending order,
> deadlock is guaranteed not to occur.
I still don't understand how the "ascending order" has anything to do
with locks.
Assume process 1 reserves resource 1, and then wants to also reserve
resource 2. However, resource 2 has already been reserved by process 2,
which means that process 1 has to wait for it to be freed. Meanwhile
process 2 tries to also reserve resource 1, but it's already reserved
by process 1, so process 2 has to wait. They are in a deadlock, waiting
for each other.
What does any "ascending order" of locks have anything to do with this?
(Btw, if you are curious, the above is the classical "dining philosophers
problem" with two processes and two resources. There could be more processes
and resources, forming a ring, with the same deadlock possibility.)
--
- Warp
Post a reply to this message
|
![](/i/fill.gif) |