Which CPU architectures support Compare And Swap (CAS)?

前端 未结 10 1829
野性不改
野性不改 2020-12-12 15:53

just curious to know which CPU architectures support compare and swap atomic primitives?

10条回答
  •  难免孤独
    2020-12-12 16:17

    Powerpc has more powerful primitives available: "lwarx" and "stwcx"

    lwarx loads a value from memory but remembers the location. Any other thread or cpu that touches that location will cause the "stwcx", a conditional store instruction, to fail.

    So the lwarx /stwcx combo allows you to implement atomic increment / decrement, compare and swap, and more powerful atomic operations like "atomic increment circular buffer index"

提交回复
热议问题