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. CSP:CSP认证考试:202012-1(期末预测之安全指数)满分答案,Java版
  2. 【机器视觉】 dev_close_tool算子
  3. 最新天猫面试题(含总结):线程池+并发编程+分布式设计+中间件
  4. Eclipse配置自动补齐键为alt+/
  5. C/C++——各种类型int、long、double、char表示范围(最大最小值)
  6. POJ 1986:Distance Queries(倍增求LCA)
  7. 20200805:Java拓扑排序实现力扣207课程表
  8. 漏洞复现——Apache HTTPD多后缀解析漏洞
  9. 服务器控制台网页登录,云服务器管理控制台登录网站
  10. 微信小程序引入字体图标 1
  11. 推荐一款博客备份工具!
  12. 彻底卸载360画报(流氓屏保软件)---亲测有效
  13. MATLAB2018B下用Faster-RCNN做目标检测的训练和测试步骤
  14. php array的用法,PHP array() 函数用法及示例
  15. 高斯RBF核函数中Sigma取值和SVM分离面的影响
  16. Pixhawk RPi CM4 Baseboard 树莓派CM4安装Ubuntu20.04 server 配置ros mavros mavsdk
  17. 轻松一下,我的成长历程,看看我历次的msn签名:)
  18. 如何使用HTTP代理促进业务
  19. GBase 8a 数据查询性能
  20. 关于什么都不会的阿里云服务器搭建及项目部署过程

热门文章

  1. Linux中date命令用法及大小比较
  2. java classifier_Java ZeroR.buildClassifier方法代码示例
  3. 《剑指Offer》——二维数组中的查找(JZ1)C++
  4. 第5章 线性回归算法
  5. Windows键盘驱动结构与消息机制--转
  6. Hessian 原理分析--转
  7. 大型web系统数据缓存设计-l转载
  8. 作为大数据和云计算学习的一个序吧
  9. Lesson 16.4 卷积遇见深度学习
  10. 机器学习-数据科学库(第一天)