Thread (24 messages) flat view 24 messages, 4 authors, 2016-06-15

Re: [PATCH 1/5] MSVC: Windows-native implementation for subset of Pthreads API

From: Johannes Sixt <hidden>
Date: 2016-06-15 22:48:00

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help