Linked by Hadrien Grasland on Fri 27th May 2011 11:34 UTC
Permalink for comment 474862
To read all comments associated with this story, please click here.
To read all comments associated with this story, please click here.
Features
Linked by Thom Holwerda on 05/20/13 11:29 UTC
Linked by Thom Holwerda on 05/18/13 21:33 UTC
Linked by David Adams on 05/16/13 4:23 UTC
Linked by Thom Holwerda on 05/11/13 21:41 UTC
Linked by Thom Holwerda on 05/08/13 14:22 UTC
Linked by Thom Holwerda on 05/02/13 15:28 UTC
Linked by Thom Holwerda on 04/29/13 21:06 UTC
Linked by Thom Holwerda on 04/24/13 22:24 UTC
Linked by Thom Holwerda on 04/18/13 11:21 UTC
Linked by Thom Holwerda on 04/16/13 9:29 UTC
More Features »
Sponsored Links



Member since:
2011-01-28
JAlexoid,
"If it's on another thread then that is not in the same call stack, is it?"
I think the problem was brought up in terms of one stack, but the situation could happen with more.
"Otherwise that problem has been successfully mitigated using reentrant mutexes, such as used in Java."
I had never heard of this terminology.
A "reentrant mutex" allows a single thread to acquire a mutex multiple times from the same thread without blocking.
However I don't think it solves the problem.
Presumably mutex a is being used to protect a structure which is in an incomplete transitionary state (which would make it detrimental for a 2nd instance of A to continue without blocking).
On the other hand, if we know that A is reentrant and it is safe to let other drivers call A again, then the solution would be to just release the mutex before calling the other drivers.
"But the problem is really bad where you use sub-threads that access a shared resource."
For illustration...
Thread 1:
Driver A (acquire reentrant mutex a)
- Driver B
-- Spawn thread 2
-- Misc work
-- Join thread 2
Thread 2:
Driver B
- Driver A (deadlock on reentrant mutex a)
- exit thread
This scenario isn't all that unreasonable. I'm not certain where a reentrant mutex would be beneficial? Certainly it could be emulated using thread local storage.