How does x86 pause instruction work in spinlock *and* can it be used in other scenarios?

前端 未结 4 988
不思量自难忘°
不思量自难忘° 2020-12-01 02:35

The pause instruction is commonly used in the loop of testing spinlock, when some other thread owns the spinlock, to mitigate the tight loop. It\'s said that it

4条回答
  •  -上瘾入骨i
    2020-12-01 03:38

    The PAUSE instruction also appears to be used in hyper-threading processors to mitigate performance impact on other hyper threads, presumably by relinquishing more CPU time to them.

    The following Intel article outlines this, and not surprisingly recommends avoiding busy wait loops on such processors: https://software.intel.com/en-us/articles/long-duration-spin-wait-loops-on-hyper-threading-technology-enabled-intel-processors

提交回复
热议问题