先引入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的更多相关文章

  1. Android 性能优化(20)多核cpu入门:SMP Primer for Android

    SMP Primer for Android 1.In this document Theory Memory consistency models Processor consistency CPU ...

  2. memory barrier 内存屏障 编译器导致的乱序

    小结: 1. 很多时候,编译器和 CPU 引起内存乱序访问不会带来什么问题,但一些特殊情况下,程序逻辑的正确性依赖于内存访问顺序,这时候内存乱序访问会带来逻辑上的错误, 2. https://gith ...

  3. 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 ...

  4. C11 memory_order

    概念: 摘录自:http://preshing.com/20120913/acquire-and-release-semantics/ Acquire semantics is a property ...

  5. 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 ...

  6. 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 ...

  7. 深入理解java内存模型

    深入理解Java内存模型(一)——基础 深入理解Java内存模型(二)——重排序 深入理解Java内存模型(三)——顺序一致性 深入理解Java内存模型(四)——volatile 深入理解Java内存 ...

  8. 深入理解Java内存模型之系列篇

    深入理解Java内存模型(一)——基础 并发编程模型的分类 在并发编程中,我们需要处理两个关键问题:线程之间如何通信及线程之间如何同步(这里的线程是指并发执行的活动实体).通信是指线程之间以何种机制来 ...

  9. 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 ...

随机推荐

  1. 《DSP using MATLAB》Problem 5.28

    昨晚手机在看X信的时候突然黑屏,开机重启都没反应,今天维修师傅说使用时间太长了,还是买个新的吧,心疼银子啊! 这里只放前两个小题的图. 代码: 1. %% ++++++++++++++++++++++ ...

  2. Http&Tomcat

    一张图 tomcat的安装和启用: Tomcat有安装版和解压版(绿色版)安装版以.exe形式的安装包,双击安装到我们的电脑上,用的比较少.解压版,即绿色版,解压后直接使用,用的比较多 bin:脚本目 ...

  3. LinkedList(实现了queue,deque接口,List接口)实现栈和队列的功能

    LinkedList是用双向链表结构存储数据的,很适合数据的动态插入和删除,随机访问和遍历速度比较慢. 底层是一个双向链表,链表擅长插入和删除操作,队列和栈最常用的2种操作都设计到插入和删除 impo ...

  4. oracle完全恢复数据库

    完全恢复数据文件 rman target/ list backup summary; 查看是否有备份,如果没有备份,先进行全备份(应该是backup database吧) 现在模拟删除oracle数据 ...

  5. C语言函数指针的使用

    使用函数指针时一定要注意,因为c不会检查参数是否正确 区分返回指针的函数和函数指针 int *f4();返回一个整数指针 int (*f5)();返回整数的函数指针 int * (*f6)();返回整 ...

  6. Android资源收集

    1 android studio最新版本下载地址:https://developer.android.google.cn/studio/preview/?utm_source=android-stud ...

  7. pghoard 面向云存储的pg 备份&&恢复工具

    pghoard 面向云存储的pg 备份&&恢复工具 包含的特性 自动定期basebackup 自动事务日志(WAL / Xlog软件)备份(使用pg_receivexlog, arch ...

  8. PowerDesigner ---- 数据库设计(物理模型CDM和概念模型PDM)

    前言 上一篇介绍了个PowerDesigner工具的安装和汉化,现在我就说一下怎么用这个PowerDesigner建数据库吧.   内容 第一种方法:概念模型转物理模型 1.首先新建模型--选择概念模 ...

  9. 应用端连接MySQL数据库报Communications link failure

    事情的起因: 某项目的开发同学突然Q我们组的某同学,要求我们调整MySQL的连接等待超时参数wait_timeout.要求我们从28800s调整到31536000s(也就是一年) 应用端测试环境的to ...

  10. Apache 配置Https 转发Tomcat Http

    Apache 相对于nginx的配置对比起来相当复杂啦,朋友之前的系统使用的是Apache需要增加一个虚拟主机,主要配置从Apache转发Tomcat. 首先需要拆解下步骤: Apache 支持Htt ...