On 7/17/06, Alexandre Julliard <[EMAIL PROTECTED]> wrote:
"Dan Kegel" <[EMAIL PROTECTED]> 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.

I was thinking that cloning the process could take care of deadlocks.
What if the cloned thread fudges its teb and sets a different thread
id than its cloning thread? This invalidates all locks in the cloned
thread taken by the cloning thread. Both threads continue and any
contention would be handled in the already thread-safe manner.

Thomas Kho


Reply via email to