Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

LL/SC is superior to CAS in that a modification to the memory will be detected even though the value has since been set back to the original value. This avoids the ABA problem.


No. CAS is superior to LL/SC. There is no possible undetected modification to the memory. That's how atomic operations work. That's the whole point of an atomic operation. It's atomic.

Botching the code can be done with either mechanism. Don't do that.


This only avoided the ABA problem if the code which is ABA prone is run in-between the LL and SC instruction.

But this is where the problem starts. E.g. for RISC when using LR/SC in a way which prevents ABA your are always losing all forward guarantees and it's totally valid for a implementation to be done in a way which will just never complete in such cases...


Looks like someone read the Wikipedia link posted in a sibling comment ;)


Well, actually, I discovered this when I was playing with implementing a lock free queue in shared memory. I was using singly linked lists; one for the queue and one for the free list. A node would sometimes come back to the queue's head from the free list and mess things up. It's not surprising that this is well known, but I learnt it by doing. :)


Yeah, that's fair, just poking fun at Wikipedia having the exact same thing paraphrased slightly differently ;)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: