Re: [PATCH 1/5] MSVC: Windows-native implementation for subset of Pthreads API
- From
Johannes Sixt <j6t@kdbg.org>
- Date
- Jan 13, 2010, 18:40 UTC
- Message-ID
- <201001131940.43868.j6t@kdbg.org>
- In-Reply-To
- <20100113125312.GD10586@dpotapov.dyndns.org>
On Mittwoch, 13. Januar 2010, Dmitry Potapov wrote:
Show 12 quoted lines
> On Tue, Jan 12, 2010 at 10:13:38PM +0100, Johannes Sixt wrote: > > In particular, it doesn't say that it is atomic WRT reads such as we have > > > > here: > > > >> + /* 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:
>> + 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