|
From: Dan K. <da...@ke...> - 2003-08-18 18:33:37
|
John Reiser wrote: >> Well, surely the buffer pointer updates need to be protected, unless >> you're using strictly atomic operations? > > No, the buffer pointer updates do not need to be "protected". As long > as the width of the pointer equals the width of the memory bus [or pointer > is narrower and the memory has natural operations of that width, and the > code uses them], and the storage for the pointer itself is naturally > aligned > [width divides address], then ordinary load and store operations suffice. > This is commonly the case; the significant exceptions are on "8-bit" > (or less) microcontrollers where a pointer is wider than the memory bus. Don't forget the other significant exception, which is on SMP machines. You may need memory barrier instructions to avoid caching problems if variables are used by more than one processor. Semaphores provide the needed memory barriers. I'm sure some pthread stuff does, too. Volatile variables don't, I think (except maybe in Java :-) It's such a pain that I personally use synchronous signal delivery for absolutely everything... - Dan -- Dan Kegel http://www.kegel.com http://counter.li.org/cgi-bin/runscript/display-person.cgi?user=78045 |