|
 |
Stefan Viljoen wrote:
> Isn't this what a mutex (like it is implemented in the Linux kernel) is for?
No. He's talking about taking and holding multiple mutexes.
There are officially five ways to prevent deadlocks. Let's see if I can
remember them from memory:
1) Lock things in order, as you say.
2) Don't hold a lock while waiting for another lock.
I.e., immediately roll back if you can't immediately aquire a lock.
3) Aquire all locks you'll need before you start processing.
E.g., "run this job where there's a video tape reader, a CD burner,
and a DSP available."
4) Only lock one thing, obviously.
5) Hmmmm... It's taking me too long to remember. :-)
But yeah, there's a formal mathematical proof that you can avoid deadlock in
exactly five ways.
--
Darren New, San Diego CA, USA (PST)
I ordered stamps from Zazzle that read "Place Stamp Here".
Post a reply to this message
|
 |