On Mittwoch, 13. Januar 2010, Dmitry Potapov wrote:
On Tue, Jan 12, 2010 at 10:13:38PM +0100, Johannes Sixt wrote:
quoted
In particular, it doesn't say that it is atomic WRT reads such as we have
here:
quoted
quoted
quoted
+ /* we're done waiting, so make sure we decrease waiters count
*/ + EnterCriticalSection(&cond->waiters_lock);
+ --cond->waiters;
+ LeaveCriticalSection(&cond->waiters_lock);
and these lines should be replaced with
InterlockedDecrement(&cond->waiters)
Ah, yes, of course. I quoted the wrong section, sorry. By "atomic WRT reads" I
meant this snippet:
quoted
+ EnterCriticalSection(&cond->waiters_lock);
+ have_waiters = cond->waiters > 0;
+ LeaveCriticalSection(&cond->waiters_lock);
Is there "InterlockedRead()"? I suppose no, but I would get confirmation that
a simple memory mov instruction is atomic WRT Interlocked* functions.
-- Hannes