[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [OT] Win32 condition variable implementation

From: Philip Martin <philip_at_codematters.co.uk>
Date: 2003-09-10 18:18:53 CEST

mark benedetto king <mbk@lowlatency.com> writes:

> On Wed, Sep 10, 2003 at 04:13:37PM +0100, Philip Martin wrote:
>> thread 1 waits
>> thread 2 waits
>> thread 3 broadcasts
>> thread 1 wakes up and runs
>> thread 1 acquires mutex and calls wait
>> thread 1 blocks waiting for cond->mutex held by thread 3
>> thread 2 tries to wake up but blocks waiting for mutex held by thread 1
>
> Aha! I knew there was something suspicious about the use of mutex.
>
> What if we were to move "release(mutex)" to the first line of wait()?

So a thread would do acquire(mutex) then wait(cond,mutex) and the
wait() would immediately release(mutex)? The mutex doesn't seem to be
protecting anything, it's a bit strange.

Another concern, your algorithm has the broadcast thread blocking for
an ack from each waiting thread. I suppose that may be acceptable
POSIX behaviour, but it's less than ideal. Your first algorithm had a
non-blocking broadcast, although it had other problems.

-- 
Philip Martin
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Sep 10 18:19:46 2003

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.