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_cstand 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 ...
随机推荐
- 下载B站、秒拍等视频网站视频
需要一个FVD Downloader(插件) 安装过程很简单,会浏览器安装插件的就不多说了!
- Python知识点整理,基础5 - 文件操作
- 使用nvm-windows安装nodejs遇到的问题(转载)
##使用nvm-windows安装nodejs遇到的问题 ####问题概述 由于国内网络限制导致使用nvm(nvm-windows,以下都使用nvm简称)安装nodejs超时或出现远程连接被关闭的问题 ...
- sofa graphql 2 rest api框架
sofa 是一个出发点不一样的工具,提供了从graphql 2 rest 的处理,一般现有的框架都在 关注的是rest 2 graphql (大部分还是基于swagger.open api 标准进行设 ...
- 如何利用 Chrome 来模拟移动网络来调试 FastAdmin 网站
如何利用 Chrome 来模拟移动网络来高度 FastAdmin 网站 因为目前大多数都在开发移动类的网页,所以客户端的速度下载速度要也考虑. 虽然都已经 4G 了,但还是要看看在网络质量很差的情况 ...
- C 语言中的 switch 语句 case 后面是否需要加大括号
事件原由为编辑器的自动缩进,当 case 换行后不自动缩进. 于是在在想可以可否在 case 后面再大括号,让其自动缩进. 查了资料,发现 case 是可以加大括号的,相当于代码块. 而且还有另外一个 ...
- centos7编译安装php7.2
去官网下载php7.2安装包,选择一个结点下载:http://php.net/downloads.php 下载:wget -ivh http://cn.php.net/distributions/ph ...
- java String的intern()方法
intern()方法用于将字符串对象加入常量池中. public native String intern(); intern()方法返回的是一个常量池中的String对象(即常量池中某个String ...
- ASP.NET AJAX入门系列(2):使用ScriptManager控件
ScriptManager控件包括在ASP.NET 2.0 AJAX Extensions中,它用来处理页面上的所有组件以及页面局部更新,生成相关的客户端代理脚本以便能够在JavaScript中访问W ...
- 图数据库cayley+mongo的起航之旅
图数据库,目前比较主流的可能是Neo4j以及cayley了.但是,由于Neo4j只有社区版是免费的,所以,选择cayley作为项目的最终选择! 今天就简单的介绍下,我的起航之旅. 1.安装go语言环境 ...