Previous | Next --- Slide 5 of 39
Back to Lecture Thumbnails
gogogo

What's the intuition behind compare and swap as a "default" operation? It seems kinda contrived.

bpr

@gogogo, with compare and swap, you can implement any set of operations on a single location as an atomic update. Only LL/SC has equivalent power.

yeezus98

Why is atomicCAS atomic? We're not doing anything to ensure the atomicity are we?

petrichor

@yeezus98 atomicCAS is defined to be an atomic operation in hardware, so there is an assembly instruction that ensures that it is atomic. I think the code there is just to illustrate what it does, but that that whole function is being done automatically as part of one assembly instruction (like CMPXCHG)