Subj : Re: sem_getvalue (was Re: Using hierarchical memory ...) To : comp.programming.threads From : Alexander Terekhov Date : Mon Sep 12 2005 09:24 pm Joe Seigh wrote: [...] > > Conflation or non-conflation aside for a moment, I'm just curious how > > your lock-free sem_getvalue() for x86 would look like. Care to share? > > > > Depends. The documentation for that is a little strange and it's not > clear if sem_getvalue has any practical use. http://www.opengroup.org/austin/mailarchives/ag/msg08586.html > > To be on the safe side you might have to use the same synchronization > that the rest of the semaphore implementation uses to set the semaphore > value. Though I might be inclined, if it looks like all you could use > sem_getvalue for is as a simple event synchronization object, to just > to do a simple load followed by a mfence, acquire semantics. It's basically For a simple x86 load from WB memory, you'll get acquire semantics "for free" no matter whether you want it or not. But acquire doesn't mean remote write atomicity... illusion of which can be achieved via a dummy RMW inside lock-free sem_getvalue() (instead of a simple load... irrespective of implied or extra added fences) on archs like x86/WB (processor consistency) or Power. regards, alexander. .