locks on X86
Jeff Sturm
jsturm@one-point.com
Mon Mar 12 15:27:00 GMT 2001
On 2001年3月12日, Boehm, Hans wrote:
> - cmpxchg without a lock prefix is much faster (roughly 3x or close to 15
> cycles by my measurements) than either xchg (implied lock prefix) or lock;
> cmpxchg .
>> - cmpxchg without the lock prefix is atomic on uniprocessors, i.e. it's not
> interruptable.
Interesting. Similarly, I once noticed that an Alpha LL/SC operation is
considerably faster without the explicit memory barrier. But as far as I
know, no code takes advantage of that, not even the Linux kernel. The
same goes for unlock on machines with a relaxed memory model.
I can't see how you could modify the code at runtime however... if the
lock routine is inlined, there could be many occurences of it, and you'd
have to arrange for it to be placed in a RW segment somehow.
Jeff
More information about the Java
mailing list