简体   繁体   English

顺序一致的内存和原子寄存器

[英]Sequentially consistent memory and atomic registers

Sequential Consistency (for data race free programs, SC-DRF) is the strongest shared memory consistency model provided by modern programming languages (eg, Java or C++11). 顺序一致性 (对于无数据争用程序,SC-DRF)是现代编程语言(例如Java或C ++ 11)提供的最强的共享内存一致性模型。

In ''Art of Multiprocessor Programming'' the authors (M. Herlihy and N. Shavit) use notion of atomic register in most of the theorems throughout the book. 在《多处理器编程的艺术》一书中,作者(M. Herlihy和N. Shavit)在整本书的大多数定理中都使用了原子配准的概念。

Is it correct to say that volatile references in Java and atomics with std::memory_order seq_cst in C++ are (indistinguishable from) atomic registers? 是否正确地说Java和C ++中具有std::memory_order seq_cst原子的volatile引用是原子寄存器(无法区别)? Is it possible to observe difference between linearizable registers and atomics in C++ if its memory model guarantees sequential consistency on whole space of memory locations marked as std::atomic ? 如果C ++的内存模型保证标记为std::atomic的内存位置的整个空间上的顺序一致性,是否有可能观察到C ++中线性化寄存器与原子之间的区别?

For the C/C++ case, atomics read or modified with memory_order_seq_cst should give you everything you're looking for (atomic RMW operations, and linearizability is guaranteed.) 对于C / C ++情况,使用memory_order_seq_cst读取或修改的原子应该为您提供所需的一切(原子RMW操作,并保证了线性化)。

For java, volatile gives you linearizability of reads and writes but any serious concurrent code is probably going to want RMW (ie compare and swap) too, so look into the java Atomic package for types that also do compare and swap (I think it is not possible to achieve compare and swap yourself without using these packages or using the synchronized keyword) http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/atomic/package-summary.html 对于Java,volatile可以为您提供读写的线性化能力,但是任何严肃的并发代码也可能也需要RMW(即比较和交换),因此,请查看java Atomic包中也可以进行比较和交换的类型(我认为这是如果不使用这些程序包或使用synced关键字,则无法实现比较和交换自己) http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/atomic/package-summary.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Java编程安全/常规/原子寄存器 - Programming safe/regular/atomic registers with Java 什么是“顺序一致的执行没有数据竞争”? - What's “sequentially consistent executions are free of data races”? 原子变量是否保证内存可见性? - Does atomic variables guarantee memory visibility? 使用原子变量时的内存排序 - Memory ordering when using atomic variable 为什么在顺序一致的执行中没有数据竞争就足以保证在所有执行中都不会出现数据竞争? - Why no data races in sequentially consistent executions is enough to guarantee that there will be no data races in all executions? 为顺序访问的文件使用内存映射有什么好处吗? - Is there any benefit to using memory mapping for a sequentially accessed file? Java中共享内存中的值的原子获取和增量功能 - Atomic get and increment functionality on a value in shared memory, in Java 如何在没有 memory 可见性影响的情况下使一组语句原子化? - How to make a group of statements atomic without memory visibility effects? 线程本地缓存的变量在更新后何时与“主内存”保持一致? - When does a thread-locally cached variable makes consistent with “main memory” after being updated? Java内存模型是否允许重新排序许多原子/易变量的非同步访问? - Will the Java Memory Model permit the reordering of non-synchronized accesses of many atomic/volatile variables?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM