在他的blog post中,埃里克·利珀特说:
I note that on x86-based hardware this particular reordering of writes is actually never observed; those CPUs do not perform this optimization.
这是否意味着 x86 CPU 不存在讨论波动性和读写重新排序时所讨论的任何问题,或者他的意思是仅在这个示例中 CPU 不会重新排序?
x86_64 CPU 中会发生哪些类型的重新排序以及在什么情况下发生?
最佳答案
Does this mean that x86 CPUs do not have any of the issues that are talked about when discussing volatility and reordering of reads and writes, or does he mean that only in this example the CPU won't reorder?
这意味着存储在 x86 CPU 中不会重新排列; 负载仍然可以向后移动。那么,了解 x86 的含义很重要。在本文中,它仅指 x86,而不是其衍生产品。 x86 oostore 架构比基本 x86 实现支持更多的内存重新排序。您可以在这里获取所有详细信息: http://en.wikipedia.org/wiki/Memory_ordering
此用例有很多示例,如下所示:
- http://preshing.com/20120515/memory-reordering-caught-in-the-act/
- http://moodycamel.com/blog/2013/a-fast-lock-free-queue-for-c++
此外,重新排序不能跨越此架构上的方法调用边界。
除了重新排序之外,几乎任何 CPU 架构都可以缓存值,这是一种更明显的优化。以下是此优化的一个很好的用例:
http://www.codeproject.com/Articles/389730/The-unsung-hero-Volatile-keyword-Csharp-threading
关于c# - x86 CPU 执行哪些类型的重新排序优化?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23061111/