typedef enum memory_order {

memory_order_relaxed, // 不对执行顺序做保证

memory_order_acquire, // 本线程中,所有后续的读操作必须在本条原子操作完成后执行

memory_order_release, // 本线程中,所有之前的写操作完成后才能执行本条原子操作

memory_order_acq_rel, // 同时包含 memory_order_acquire 和 memory_order_release

memory_order_consume, // 本线程中,所有后续的有关本原子类型的操作,必须在本条原子操作完成之后执行

memory_order_seq_cst // 全部存取都按顺序执行

} memory_order;

另外rust 相关文档,写的好理解;

Relaxed

No ordering constraints, only atomic operations.

Corresponds to memory_order_relaxed in C++20.

Release

When coupled with a store, all previous operations become ordered before any load of this value with Acquire (or stronger) ordering. In particular, all previous writes become visible to all threads that perform an Acquire (or stronger) load of this value.

Notice that using this ordering for an operation that combines loads and stores leads to a Relaxed load operation!

This ordering is only applicable for operations that can perform a store.

Corresponds to memory_order_release in C++20.

Acquire

When coupled with a load, if the loaded value was written by a store operation with Release (or stronger) ordering, then all subsequent operations become ordered after that store. In particular, all subsequent loads will see data written before the store.

Notice that using this ordering for an operation that combines loads and stores leads to a Relaxed store operation!

This ordering is only applicable for operations that can perform a load.

Corresponds to memory_order_acquire in C++20.

AcqRel

Has the effects of both Acquire and Release together: For loads it uses Acquire ordering. For stores it uses the Release ordering.

Notice that in the case of compare_and_swap, it is possible that the operation ends up not performing any store and hence it has just Acquire ordering. However, AcqRel will never perform Relaxed accesses.

This ordering is only applicable for operations that combine both loads and stores.

Corresponds to memory_order_acq_rel in C++20.

SeqCst

Like Acquire/Release/AcqRel (for load, store, and load-with-store operations, respectively) with the additional guarantee that all threads see all sequentially consistent operations in the same order.

Corresponds to memory_order_seq_cst in C++20.

atomic 内存序_并行编程的内存顺序 2020-11-23相关推荐

  1. 1.9 编程基础之顺序查找 11 连续出现的字符 python

    http://noi.openjudge.cn/ch0109/11/ """ 1.9 编程基础之顺序查找 11 连续出现的字符 http://noi.openjudge. ...

  2. 全面理解java内存模型_深入理解Java内存模型(八)——总结

    处理器内存模型 顺序一致性内存模型是一个理论参考模型,JVM和处理器内存模型在设计时通常会把顺序一致性内存模型作为参照.JVM和处理器内存模型在设计时会对顺序一致性模型做一些放松,因为如果完全按照顺序 ...

  3. java if在内存中_全面理解Java内存模型

    Java 内存模型的抽象 在 java 中,所有实例域.静态域和数组元素存储在堆内存中,堆内存在线程之间共享(本文使用"共享变量"这个术语代指实例域,静态域和数组元素).局部变量( ...

  4. linux内存管理_浅谈Linux内存管理

    1. 扫盲篇 1.1 操作系统存储层次 常见的计算机存储层次如下: 寄存器:CPU提供的,读写ns级别,容量字节级别. CPU缓存:CPU和CPU间的缓存,读写10ns级别,容量较大一些,百到千节. ...

  5. r720支持多少频率的内存吗_内存条全面选购指南,2020年有哪些内存条值得推荐...

    *文章末尾有内存条推荐. 电脑内存(RAM)是程序运行的地方,当你打开一款软件.游戏时,系统会将硬盘中的必要数据复制到内存中,CPU 再从内存中获取数据,因为内存的速度比硬盘要快的多多多.唯一的遗憾是 ...

  6. 内存溢出_关于PermGen Space内存溢出解决方案

    内存溢出分为Heap Space和PermGen Space两种异常.正巧的是我这次就碰到了PermGen space异常,为了解决这个异常花了我 半天的时间,所以今天写这个方案就是做一种笔记. 刚开 ...

  7. jvm内存结构_浅谈JVM内存结构

    JVM 可以分为 5 个部分,分别是: 类加载器(Class Loader):加载字节码文件到内存. 运行时数据区(Runtime Data Area):JVM 核心内存空间结构模型. 执行引擎(Ex ...

  8. unity如何检测内存泄漏_如何排查Java内存泄漏?看懂这一篇就够用了

    原文:https://www.toptal.com/java/hunting-memory-leaks-in-java 作者:Jose Ferreirade Souza Filho 译者:Emma来源 ...

  9. java怎么看内存值_【java】内存分析

    在J2SE中,通过进行内存分析,可以让我们更好的理解我们的程序在内存中是怎么被分配内存的.也能让我们更好的理解我们的代码是怎么运行的. 对于我自己来说分析内存也是一件很有趣的事情.所以下面通过一个例子 ...

最新文章

  1. iframe 有那些缺点?
  2. 倒频谱原理与python实现
  3. minst0-9对应81-30-3的特征频率曲线
  4. Java多线程知识小抄集(二)
  5. android加载声音文件,Android是在应用程序中加载和播放声音的最快方式
  6. qt设置圆形按钮_Qt开源作品25-电池电量控件
  7. 5个Python特性 越早知道越好的
  8. 数字逻辑之组合逻辑电路
  9. 无废话Git——本地服务器提交撤销
  10. 分布式压缩感知 matlab程序,BCS_CODE 贝叶斯压缩感知以及分布式 的算法实现,很好的范例 matlab 238万源代码下载- www.pudn.com...
  11. 活灵活现用Git-技巧篇
  12. 阿里巴巴国际站 | 如何做数据分析?
  13. Failed to create/setup connection: 驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接。
  14. iOS各种被拒的原因汇总
  15. 如何运行matlab代码?怎样找到matlab主程序?
  16. QQ的在线拼音输入法
  17. Algorithm(算法
  18. Item 5:Know what functions C++ silently writes and calls
  19. oracle2周后日期,ORACLE日期时间及数字的格式化参数大全
  20. 【python读取excel文件保存为矩阵形式】

热门文章

  1. 使用insert向表中添加数据MySQL_使用INSERT语句向表中插入数据(MSSQLSERVER版)
  2. 5类6类7类网线对比_未来值得投资的6类苗木,5年内市场前景应该都不错!
  3. 【Linux】13_ 文件查找
  4. Anaconda中快速安装Tensorflow与Keras并在pycharm中完成相应配置(win10cpu版)
  5. LeetCode-动态规划背包题-1049. 最后一块石头的重量 II
  6. JVM源码分析之javaagent原理完全解读--转
  7. log4j配置文件详解---转
  8. redis 控制调用频率
  9. 金融风控实战——信贷业务架构与业务分析
  10. Chrome报错:Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist.