A
Andreas Leitgeb
So you meant to have it deterministically check for a cycle *every* time
a lock acquisition was attempted?
Not every time, but only if the thread would actually go into blocking
state *and* already holds a lock. My reasons for favoring my approach to
a watchdog (that's how I understood yours) is, that here we have a trigger
(namely a thread with a lock in its hand trying to grab another one and
not immediately getting that other one) that immediately points us to a
candidate, whereas the watchdog would have to be actively checking through
all existing threads for one being deadlocked, each period.
I believe it is not a significantly expensive pre-check and for those
threads that meet this condition, it is worth the trouble to follow
the chain in search of a loop.
Those cases of high throughput are those where the lock is immediately
available, and I don't yet see anything changing about that.
One thing, that makes my idea a bit hard to understand, is that I'm
talking of a thread doing something (namely searching through the
lock-chain for a loop), while actually in blocked state. That sure
requires some new pitch black jvm magic, but I don't consider it
unthinkable.