简体   繁体   English

memory 线程之间的栅栏/障碍如何与其他线程中的栅栏/障碍交互?

[英]How do memory fences/barriers among threads interact with fences/barriers in other threads?

What is the interaction of memory fences in different threads? memory栅栏在不同线程中的交互是什么?

More particularly does a memory fence in a thread only prevents the reordering of instructions within the thread or there is there synchronising among the threads like one thread waits until the corresponding fence is reached in another thread?更具体地说,线程中的 memory 栅栏是否仅防止线程内指令的重新排序,或者线程之间是否存在同步,就像一个线程等待直到在另一个线程中达到相应的栅栏? What happens is multiple threads have the same type of fence and multiple threads have paired fences?如果多个线程具有相同类型的栅栏并且多个线程具有成对的栅栏,会发生什么情况? What type of fences needs to pair together among threads and how are they used?什么类型的栅栏需要在线程之间配对,它们是如何使用的? What are the effects if the code with memory fences is run in a single-threaded fashion?如果带有 memory 栅栏的代码以单线程方式运行会产生什么影响?

A memory barrier is nothing like the tag. memory 屏障与标签完全不同。

Memory barriers only order the local core's own accesses to coherent shared memory, because that's all that's needed to be able to recover sequential consistency. Memory 屏障仅命令本地内核自己访问一致的共享 memory,因为这就是恢复顺序一致性所需的全部。 There is no direct interaction with other threads / cores.与其他线程/内核没有直接交互。

If you want synchronization between threads, use release/acquire ordering.如果您想要线程之间的同步,请使用发布/获取顺序。https://preshing.com/20120913/acquire-and-release-semantics/https://preshing.com/20120913/acquire-and-release-semantics/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM