Subj : sem_getvalue (was Re: Using hierarchical memory ...) To : comp.programming.threads,comp.arch From : Joe Seigh Date : Mon Sep 12 2005 03:00 pm (followup set to comp.programming.threads) Alexander Terekhov wrote: > Joe Seigh wrote: > [...] > >>I try not to conflate specification and implementation. > > > 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. 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 a question of what the observable behavior is no matter what the documentation says. I see you've been looking for places to use your compare and swap "synchronized" load trick. :) -- Joe Seigh When you get lemons, you make lemonade. When you get hardware, you make software. .