In managed languages how is atomicity of reference operations enforced?
On some platforms references have to be at least 64 bit, so it cannot rely on usually atomic 32 bit word operations...
Is it done simply through the use of locks? Wouldn't that be considered too costly in terms of performance?
To be more precise I didn't mean all reference operations, I mean mostly assignment which is atomic in for example .NET and Java. But even assignment is not obviously atomic since on most platforms you cannot reliably change value of 64 bit word in atomic way...
AtomicReference
type or something like that.AtomicReference
is needed for atomic compare-and-swap and get-and-set.movq
already does that. Remember, you can't have 64 bit references on IA-32.