
7 Apr
2005
7 Apr
'05
12:31 p.m.
Peter Dimov wrote: [...]
and an acquire when the new value is zero.
Hmm, tricky. There would be need to be another instruction afterward that creates the acquire barrier. Maybe this would do:
__asm__ (" fetchaddl.rel %0=[%4],-1 \n" " cmp.eq %2,%3=1,%0 \n" "(%2) ldl.acq %0=[%4] " : "=r"(rv), "=m"(*pw), "=c", "=c" : "r"(pw) : );
Don't ask me whether that's the most efficient way to do this!
That's RAW dependency on a semaphore. It isn't optimal for refcounting because it equates to a full fence, not mere acquire. BTW, you need a "memory" clobber clause here (not sure about cc/predicate stuff). regards, alexander.