GCC memory barrier __sync_synchronize vs asm volatile(“”: : :“memory”)

前端 未结 2 676
长发绾君心
长发绾君心 2020-12-04 19:58

asm volatile(\"\": : :\"memory\") is often used as a memory barrier (e.g. as seen in the Linux kernel barrier macro).

This sounds similar t

2条回答
  •  一向
    一向 (楼主)
    2020-12-04 20:02

    A comment on the usefulness of SW-only barriers:

    On some micro-controllers, and other embedded platforms, you may have multitasking, but no cache system or cache latency, and hence no HW barrier instructions. So you need to do things like SW spin-locks. The SW barrier prevents compiler optimizations (read/write combining and reordering) in these algorithms.

提交回复
热议问题