Hi,
On Mon, Jul 17, 2006 at 01:08:38PM +0200, Alexandre Julliard wrote:
"Dan Kegel" dank@kegel.com writes:
I'm afraid I don't quite understand. What's wrong with interrupting a thread holding a lock? Could that make cloning a new thread deadlock?
One problem is that many locks have to be acquired in a specific order to avoid deadlocks, and since you don't know which locks the thread is already holding you can't guarantee the order. The other problem is that you can't guarantee that critical sections are in a valid state since the thread could be interrupted in the middle of a crit section call.
The second problem could possibly be workarounded by some very gross hacks:
Add hooks in a number of *very* common Win32 API functions (GetVersion(), PeekMessage(), ...) that would "trap" this thread there (add huge Sleeps etc.) while it's being grossly abused externally:
if (unlikely(ongoing_create_remote_operation)) freeze_thread();
That way you'd make certain that any object the thread is modifying during its life-time is not suspended in half-modified state during the time that you're doing brain surgery on this thread.
Not a pretty solution at all, but it could help - unless I'm totally mistaken due to uninformedly jumping into the middle of this discussion.
Andreas Mohr