cmpxch8b instruction
From: James Brown (spamtrap_at_crayne.org)
Date: 03/28/05
- Next message: Nathan Moore : "Re: Global Variable vs Struct Variable Question"
- Previous message: Jonny: "Re: Reading a sector"
- Next in thread: Alex McDonald: "Re: cmpxch8b instruction"
- Reply: Alex McDonald: "Re: cmpxch8b instruction"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 28 Mar 2005 18:01:20 +0000 (UTC)
All,
I have a requirement to write 8 bytes to a memory location
in an "atomic" operation - i.e. with the LOCK instruction prefix. I'm
working
in 32bit protected mode (x86 ms-windows)
The CMPXCHG8B instruction seems promising, but there is no
corresponding XCHG8B instruction. From the description of
the cmpxchg8b instruction it looks as if I will need to execute it twice:
once to load the destination memory contents into EDX:EAX,
then when I know what this 64bit value is, execute it again to
actually write my intended values.
mov eax, 0
mov edx, 0
mov ebx, [low_dword]
mov ecx, [high_dword]
lock cmpxchg8b [address] ; call once to load edx:eax
lock cmpxchg8b [address] ; call again to force write
The problem is my "atomic" write operation is now flawed
(two operations not one) Any advise on what to do here?
Speed is not an issue, would prefer short+simple rather than clever+obscure
:-)
Thanks,
James
- Next message: Nathan Moore : "Re: Global Variable vs Struct Variable Question"
- Previous message: Jonny: "Re: Reading a sector"
- Next in thread: Alex McDonald: "Re: cmpxch8b instruction"
- Reply: Alex McDonald: "Re: cmpxch8b instruction"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|