Sequentially-consistent ordering
先引入cppreference中的描述:
Atomic operations tagged memory_order_seq_cst not only order memory the same way as release/acquire ordering (everything that happened-before a store in one thread becomes a visible side effect in the thread that did a load), but also establish a single total modification order of all atomic operations that are so tagged.
Formally,
Each memory_order_seq_cst
operation B that loads from atomic variable M, observes one of the following:
- the result of the last operation A that modified M, which appears before B in the single total order
- OR, if there was such an A, B may observe the result of some modification on M that is not
memory_order_seq_cst
and does not happen-before A - OR, if there wasn't such an A, B may observe the result of some unrelated modification of M that is not
memory_order_seq_cst
然后,让我们查看以下sequentially consistent的模型[1]:
One might expect multiprocessors to have sequentially consistent (SC) shared memory, in which, as articulated by Lamport [Lam79]:
“the result of any execution is the same as if the operations of all the processors were executed in some sequential order, and the operations of each individual processor appear in this sequence in the order specified by its program”.
An SC machine can be modelled as in the diagram below:
Here there are a number of hardware threads, each executing code as specified by the program, which access a single shared memory (by writing and reading the values it holds at each address). Such a machine has two key properties:
1. There is no local reordering: each hardware thread executes instructions in the order specified by the program, completing each instruction (including any reads or writes to the shared memory) before starting the next.
2. Each write becomes visible to all threads (including the thread doing the write) at the same time
sequentially consistent模型简单说明:
(1)按照代码顺序从前到后执行,执行完前一条指令,然后执行下一条指令,不存在指令重排一类的情况。
(2)所有线程的所有写构成一个序列,如果在两个序列之间(运行时)存在读的话,那么这条读指令,读取的一定是前一条写的结果。
关于atomic说明:
如果所有的atomic对象的所有读写操作使用的都是std::memory_order_seq_cst,那么这些所有的atomic对象的操作满足上述的sequentially consistent模型。
Sequentially-consistent ordering的更多相关文章
- Android 性能优化(20)多核cpu入门:SMP Primer for Android
SMP Primer for Android 1.In this document Theory Memory consistency models Processor consistency CPU ...
- memory barrier 内存屏障 编译器导致的乱序
小结: 1. 很多时候,编译器和 CPU 引起内存乱序访问不会带来什么问题,但一些特殊情况下,程序逻辑的正确性依赖于内存访问顺序,这时候内存乱序访问会带来逻辑上的错误, 2. https://gith ...
- Memory Ordering in Modern Microprocessors
Linux has supported a large number of SMP systems based on a variety of CPUs since the 2.0 kernel. L ...
- C11 memory_order
概念: 摘录自:http://preshing.com/20120913/acquire-and-release-semantics/ Acquire semantics is a property ...
- The JSR-133 Cookbook for Compiler Writers(an unofficial guide to implementing the new JMM)
The JSR-133 Cookbook for Compiler Writers by Doug Lea, with help from members of the JMM mailing lis ...
- C++11开发中的Atomic原子操作
C++11开发中的Atomic原子操作 Nicol的博客铭 原文 https://taozj.org/2016/09/C-11%E5%BC%80%E5%8F%91%E4%B8%AD%E7%9A%84 ...
- 深入理解java内存模型
深入理解Java内存模型(一)——基础 深入理解Java内存模型(二)——重排序 深入理解Java内存模型(三)——顺序一致性 深入理解Java内存模型(四)——volatile 深入理解Java内存 ...
- 深入理解Java内存模型之系列篇
深入理解Java内存模型(一)——基础 并发编程模型的分类 在并发编程中,我们需要处理两个关键问题:线程之间如何通信及线程之间如何同步(这里的线程是指并发执行的活动实体).通信是指线程之间以何种机制来 ...
- System and method for parallel execution of memory transactions using multiple memory models, including SSO, TSO, PSO and RMO
A data processor supports the use of multiple memory models by computer programs. At a device extern ...
随机推荐
- hihocoder1490 Tree Restoration 模拟
There is a tree of N nodes which are numbered from 1 to N. Unfortunately, its edges are missing so w ...
- hasura graphql-engine &&patroni docker-compose 环境运行
patroni 是一个很不错的pg ha 解决方案,graphql-engine 是一个很好的graphql 工具,为了方便使用 参考patroni官方的文档,使用docker-compose 将应用 ...
- 永无BUG
/*************************************************************** * _ooOoo_ * * o8888888o * * 88" ...
- Zabbix-2.4-安装-2
zabbix自定义报警-动作 打开资产自动接收 这里看到主机资产有数据了,这里的数据,就是来自下面的关联 上面的数据就是设置login-user时候设置的关联 有些关联显示的慢,比如下面 ...
- Exception analysis
Finding: Thread 119:1f7c Exception Code 0xE06D7363 From https://support.microsoft.com/en-us/help/185 ...
- oracle之 单实例监听修改端口
Oracle 单一主机多个实例多个监听器配置要点 1. 一台服务器主机, 有多个实例, 如: TSDB/ORCL; 又需要配置多个监听器 2. 需要指定不同的LISTENER端口 3.pmon ...
- i++和++i的笔试题
i = ++i + i++ + i++ + i++; 把每个 i++或者++i看作一个部分,他们的分别再下一个 i++或者++i改变,中途赋值的话,就返回这个部分的值 来自:https://www.j ...
- 运用MQTT-JMeter插件测试MQTT服务器性能
今天我们介绍XMeter团队带来的新版MQTT-JMeter插件,您可以更为方便地添加MQTT连接.发布.订阅取样器,构造组合的应用场景,例如背景连接.多发少收.少发多收,计算消息转发时延等.利用该插 ...
- 自然语言处理工具HanLP被收录中国大数据产业发展的创新技术新书《数据之翼》
在12月20日由中国电子信息产业发展研究院主办的2018中国软件大会上,大快搜索获评“2018中国大数据基础软件领域领军企业”,并成功入选中国数字化转型TOP100服务商. 图:大快搜索获评“2018 ...
- HDFS管理工具HDFS Explorer
HDFS Explorer是一个在windows上管理HDFS系统的工具,支持上传.下载.重命.复制.移动和删除等. 一.下载地址 CSDN下载地址:http://download.csdn.net/ ...