[fpc-devel] membar instruction

Dariusz Mazur darekm at emadar.com
Sat Feb 23 21:36:08 CET 2008


Micha Nelissen pisze:
> Dariusz Mazur wrote:
>   
>>> Don't know about this one, can't you use a do nothing loop?
>>>   
>>>       
>> in spin-lock there is NOOP used, I think that is instruction, that every
>> processor do nothing but not avoid (duration is very small but not zero)
>>     
>
> Why do you use a NOP in a spin-lock?
>   
its only exaple form sparc manual, I need (I want to test) it to in my 
FIFO algo.

form SPARCV9.PDF:

LockWithLDSTUB(lock)
retry:
ldstub [lock],%l0
tst %l0
be out
nop
loop:
ldub [lock],%l0
tst %l0
bne loop
nop
ba,a retry
out:
membar #LoadLoad | #LoadStore
UnLockWithLDSTUB(lock)
membar #StoreStore !RMO and PSO only
membar #LoadStore !RMO only
stub %g0,[lock]

Example 7---Lock and Unlock Using LDSTUB


Darek



More information about the fpc-devel mailing list