* correct use of mfence
@ 2009-02-27 23:07 ramregar
0 siblings, 0 replies; only message in thread
From: ramregar @ 2009-02-27 23:07 UTC (permalink / raw)
To: linux-assembly
Hi,
I am writting atomic inc/dec/cas operations in assembly.
increment64(__int64* value, int val)
{
__int64* temp = &val;
_asm
{
push edi
push ebx
mov edi, pValue
mov eax, [edi]
mov edx, [edi+4]
again:
mov ecx, edx
mov ebx, eax
add ebx, 1
adc ecx, 0
mfence
lock cmpxchg8b [edi]
mfence
jnz again
mov eax, temp
mov [eax], ebx
mov [eax+4], ecx
pop ebx
pop edi
}
}
Requirement is that it should work on single and multi-core
hardwares.
1. Use of mfence is not clear to me. So I temporarily put mfence
before and after cmpxchg8b. I am looking for correct use of mfence
opcode in this context. I would like to know how many lines mfence
serializes before its use.
MFENCE:
This serializing operation guarantees that every load and store
instruction that precedes in program order the MFENCE instruction is
globally visible before any load or store instruction that follows the
MFENCE instruction is globally visible
2. If i use mfence then also i need to use lock opcode before
cmpxchg8b?
What is the correct use of mfence in above assembly code.
Thanks,
Ram
--
View this message in context: http://www.nabble.com/correct-use-of-mfence-tp22256244p22256244.html
Sent from the linux-assembly mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-02-27 23:07 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-27 23:07 correct use of mfence ramregar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).