C++ __sync_synchronize 有什么作用?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/982129/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What does __sync_synchronize do?
提问by Superpolock
I saw an answer to a question regarding timingwhich used __sync_synchronize().
我看到了一个关于使用 __sync_synchronize() 的时间问题的答案。
- What does this function do?
- And when is it necessary to be used?
- 这个函数有什么作用?
- 什么时候需要使用?
回答by nik
It is a atomic builtin for full memory barrier.
它是完整内存屏障的原子内置函数。
No memory operand will be moved across the operation, either forward or backward. Further, instructions will be issued as necessary to prevent the processor from speculating loads across the operation and from queuing stores after the operation.
不会在整个操作中向前或向后移动内存操作数。此外,将根据需要发出指令,以防止处理器推测整个操作的负载以及在操作之后对存储进行排队。
Check details on the link above.
检查上面链接的详细信息。
回答by Nikolai Fetissov
It forces a memory fenceI guess.
我猜它会强制使用内存栅栏。