By: nksingh (none.delete@this.none.non), August 25, 2014 3:55 am
Room: Moderated Discussions
> So getting back to LL/SC, was it considered in, say, the context of Alpha
> and Ultrix a terrible idea? Would the alternatives have been better?
LL/SC seems like a pretty cool idea, but it theoretically has a potential for livelock, and at least the ARM implementation (the only one I have practical experience with) can't be used generically using compiler intrinsics.
MSVC uses ldrex/strex to implement all the primitives that are available on x86, but the compiler can't directly expose the pair of operations since there's no way to guarantee that some other memory operation won't get scheduled in between. If that other operation happens to target an address inside the granule the ldrex/strex will perpetually fail.
This may not be a huge deal on gcc-like compilers where you can integrate asm into C code. I wonder if any compilers optimize a typical cmpxchg loop into a more intelligent ldrex/strex sequence.
> and Ultrix a terrible idea? Would the alternatives have been better?
LL/SC seems like a pretty cool idea, but it theoretically has a potential for livelock, and at least the ARM implementation (the only one I have practical experience with) can't be used generically using compiler intrinsics.
MSVC uses ldrex/strex to implement all the primitives that are available on x86, but the compiler can't directly expose the pair of operations since there's no way to guarantee that some other memory operation won't get scheduled in between. If that other operation happens to target an address inside the granule the ldrex/strex will perpetually fail.
This may not be a huge deal on gcc-like compilers where you can integrate asm into C code. I wonder if any compilers optimize a typical cmpxchg loop into a more intelligent ldrex/strex sequence.