From: Peter Harris Date: Thu, 14 Jan 2010 13:43:30 GMT Subject: Re: [PATCH 1/5] MSVC: Windows-native implementation for subset of Pthreads API Message-ID: In-Reply-To: <20100114051241.GF10586@dpotapov.dyndns.org> On Thu, Jan 14, 2010 at 12:12 AM, Dmitry Potapov wrote: > On Wed, Jan 13, 2010 at 07:40:43PM +0100, Johannes Sixt wrote: >> Is there "InterlockedRead()"? I suppose no, but I would get confirmation that >> a simple memory mov instruction is atomic WRT Interlocked* functions. > > If I were writing Interlocked API, I would certainly add InterlockedRead() > and InterlockedWrite() functions, but somehow Microsoft decided that these > functions are redundant. InterlockedWrite is spelt InterlockedExchange. > Finally, there is a paranoiac implementation of InterlockedRead(&foo): > >   result = InterlockedAdd(&foo, 0) > > but, IMHO, it is pathetic... Agreed. Another pathetic implementation: result = InterlockedCompareExchange(&foo, 0, 0); Peter Harris