On 5/30/07, George Timoshenko <[EMAIL PROTECTED]> wrote:

> I had a question in the JIRA about this issue: why don't we use "lock"
> prefix for the atomic access?

well...

Originally we split all 64-bit memory access into 2 ones of 32-bit.
It does not have sense to set #LOCK prefix for them. (there is a gap
between)

We can only set #LOCK to some instruction that reads/writes whole 64 bits.

The bad thing is the only instruction (according to IA32 spec) we can
set #LOCK to is CMPXCHG8B (MOVQ, MOVSD and any others can not be used
with #LOCK)

This monster (CMPXCHG8B) requires 4 registers:

EAX
EBX
ECX
EDX

and (FLAGS) also.

I am not sure CMPXCHG8B usage will be faster than making volatile fields
   always synchronized (artificially)

George, I believe it should be much faster than synchronized block,
since it is non-blocking with contended locks. To use compxchg, you
need a loop to check the return result till it succeeds. With
synchronized block, the thread will go to sleep till being waken up by
the releasing thread.

Thanks,
xiaofeng





--
http://xiao-feng.blogspot.com

Reply via email to