News for hackers. Stuff that matters.
Re:The x86 architecture is the weirdo (2004) by phamilton on Tuesday April 19, 2022 @04:19PM (#31088459)
I vaguely recall that LL/SC solves the ABA problem whereas load-modify-store does not.

It's been a while, so I'm going to define my understanding of the ABA problem in case I misunderstood it:

x86 only supplies cmpxchange instructions on which will update a value only if it matches the passed in previous value. There's a class of concurrency bugs where the value is modified away from it's initial value and then modified again back to it's value. cmpxchange can't detect that condition, so if it's a meaningful difference often the 128-bit cmpxchange will be used with a counter in the second 64-bits that is incremented on each write to catch this case.

LL/SC will trigger on any write, rather than comparing the value, providing the stronger guarantee.

(Please correct me if this is inaccurate, it's been a hit minute since I learned this and I'd love to be more current on it).

Re:The x86 architecture is the weirdo (2004) by zozbot234 on Tuesday April 19, 2022 @04:29PM (#31088615)
AIUI, a cmpxchg loop is enough to implement read-modify-write of any atomically sized value. The ABA problem becomes relevant when trying to implement more complex lock-free data structures.