CAS based algorithms - how threads sees latest values?

柔情痞子 提交于 2020-06-01 05:50:48

问题


I recently came to know about CAS - Compare and Set and I tried to know more about it. I checked online in quest to know more and came across this link.

How is it possible that without locking , using CAS threads can get / update values.

For example, in multicore processors they keep values in their own cache (and that is why we use volatile when we want threads to read latest values). So, even if, there is CAS, won't threads trying to do this operation be reading from their own cache?

Are these types of operations to be supported by Hardware? Any inputs, as a novice how to get familiar with this?

来源:https://stackoverflow.com/questions/61916128/cas-based-algorithms-how-threads-sees-latest-values

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!