I will just give the analogy with which I understand memory consistency models (or memory models, for short). It is inspired by Leslie Lamport's seminal paper "Time, Clocks, and the Ordering of Events in a Distributed System". The analogy is apt and has fundamental significance, but may be overkill for many people. However, I hope it provides a mental image (a pictorial representation) that facilitates reasoning about memory consistency models.

我会给出一个我理解的内存一致性模型(简称内存模型)的比喻。灵感来自Leslie Lamport的开创性论文“时间,时钟和分布式系统中事件的顺序”。比喻很简单,其中包含了(内存模型的)基本意义,对不少人来说可能有点矫枉过正。不管怎么说,我期望它可以提供一种图景(图形呈现)以促进理解内存一致性模型。

Let’s view the histories of all memory locations in a space-time diagram in which the horizontal axis represents the address space (i.e., each memory location is represented by a point on that axis) and the vertical axis represents time (we will see that, in general, there is not a universal notion of time). The history of values held by each memory location is, therefore, represented by a vertical column at that memory address. Each value change is due to one of the threads writing a new value to that location. By a memory image, we will mean the aggregate/combination of values of all memory locations observable at a particular time by a particular thread.

我们可以通过空间-时间图来看一下全部内存位置的历史。其中横轴表示地址空间(每个内存位置是由在该轴上的点表示),纵轴表示时间(通常来说时间没有通用的概念)。因而,每个内存位置存储值的历史由该内存地址的垂直柱表示。每个值的变化是因为某个线程为该内存位置赋新值引起。通过内存图,我们可以观察特定线程在特定时间全部内存地址上值的汇总/组合情形。

Quoting from "A Primer on Memory Consistency and Cache Coherence"

The intuitive (and most restrictive) memory model is sequential consistency (SC) in which a multithreaded execution should look like an interleaving of the sequential executions of each constituent thread, as if the threads were time-multiplexed on a single-core processor.

引自“存储一致性和Cache一致性入门”

直观的(也是最严格的)内存模型是顺序一致性。多线程的执行应该看起来是每个线程顺序执行的交织,仿佛线程在单核处理器上的时间复用。

That global memory order can vary from one run of the program to another and may not be known beforehand. The characteristic feature of SC is the set of horizontal slices in the address-space-time diagram representing planes of simultaneity (i.e., memory images). On a given plane, all of its events (or memory values) are simultaneous. There is a notion of Absolute Time, in which all threads agree on which memory values are simultaneous. In SC, at every time instant, there is only one memory image shared by all threads. That's, at every instant of time, all processors agree on the memory image (i.e., the aggregate content of memory). Not only does this imply that all threads view the same sequence of values for all memory locations, but also that all processors observe the samecombinations of values of all variables. This is the same as saying all memory operations (on all memory locations) are observed in the same total order by all threads.

全局内存顺序可以从程序的一个运行到另一个运行,并且可能事先不知道。顺序一致性(SC)的特点是在地址空间图中代表平面性水平切片的集合(即存储图像)。在一个给定的平面上,它所有的事件(或内存值)是同时发生的。有一个绝对时间的概念,其中所有的线程都认同内存值是同时的;在顺序一致性(SC)中,每一个时刻,所有线程共享唯一一个内存图像。也就是说,在每一个瞬间的时间,所有的处理器都认同的内存映像(即,内存的总含量). 这不仅意味着,在全部内存位置上,所有的线程查看到的值的顺序是相同的,而且全部的处理器观察到的所有变量的值的组合都是一样的。换句话说,全部线程的所有内存操作(在所有的内存位置)看起来是在一个相同的总的顺序里。

[翻译]内存一致性模型 --- memory consistency model的更多相关文章

  1. 一致性模型(consistency model)

    比如下面的例子: 一行X值在节点M和节点N上有副本 客户端A在节点M上写入行X的值 一段时间后,客户端B在节点N上读取行X的值 一致性模型所要做的就是决定客户端B能否看到客户端A写的值.一致性模型分为 ...

  2. memory consistency

    目前的计算机系统中,都是shared memory结构,提供统一的控制接口给软件, shared memory结构中,为了memory correctness,可以将问题分为:memory consi ...

  3. Multi-core compute cache coherency with a release consistency memory ordering model

    A method includes storing, with a first programmable processor, shared variable data to cache lines ...

  4. Java 新内存(cache)模型解析

    JMM 相关文档: Java Language Specification Chapter 17 The JSR-133 Cookbook for Compiler Writers - Doug Le ...

  5. Java内存一致性

    问题 前段时间在做服务注册发现的时候,有一处这样的逻辑,先发现下游服务,然后再是服务启动,服务启动完毕才能注册服务,因为注册一个在启动过程中的服务显然是不正确的设计. 然而很不巧,我们目前使用的TTh ...

  6. [Paper翻译]Scalable Lock-Free Dynamic Memory Allocation

    原文: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.87.3870&rep=rep1&type=pdf Abstr ...

  7. JVM 内存分配模型概念和java中各种对象的存储

    JVM 内存分配模型概念 --在工作中可能用到的机会不多,有个概念的了解 --此文是转载某位读者,应该是在阅读了<深入理解Java虚拟机JVM高级特性与最佳实践> 一书后,总结所得.写的不 ...

  8. C# .Net 多进程同步 通信 共享内存 内存映射文件 Memory Mapped 转 VC中进程与进程之间共享内存 .net环境下跨进程、高频率读写数据 使用C#开发Android应用之WebApp 分布式事务之消息补偿解决方案

    C# .Net 多进程同步 通信 共享内存 内存映射文件 Memory Mapped 转 节点通信存在两种模型:共享内存(Shared memory)和消息传递(Messages passing). ...

  9. CSS学习笔记——视觉格式化模型 visual formatting model

    CSS 视觉格式化模型(visual formatting model)是用来处理文档并将它显示在视觉媒体上的机制.他有一套既定的规则(也就是W3C规范),规定了浏览器该怎么处理每一个盒子.以下内容翻 ...

随机推荐

  1. eas之如何获取当前用户

    在UI扩展类中,获取当前用户可通过工具类SysContext如:SysContext.getSysContext().getCurrentUserInfo()在ControlerBean的扩展类中,获 ...

  2. 洛谷P1616 疯狂的采药【完全背包】

    题目描述 LiYuxiang是个天资聪颖的孩子,他的梦想是成为世界上最伟大的医师.为此,他想拜附近最有威望的医师为师.医师为了判断他的资质,给他出了一个难题.医师把他带到一个到处都是草药的山洞里对他说 ...

  3. Java异常以及继承的一些问题

    Java异常以及继承的一些问题 http://blog.csdn.net/hguisu/article/details/6155636 https://www.cnblogs.com/skywang1 ...

  4. mongodb集群搭建(分片+副本)

    原文地址:https://www.cnblogs.com/ityouknow/p/7344005.html 相关概念 先来看一张图: 从图中可以看到有四个组件:mongos.config server ...

  5. bzoj 2654 && bzoj 3675 总结

    手动博客搬家: 本文发表于20180929 15:18:55, 原地址https://blog.csdn.net/suncongbo/article/details/82897992 最近做到了两道( ...

  6. 生成PW配置和BFD配置

    保存在配置文件中 def Main(): buf = '' f = open('pw.cfg','w') for i in range(2016): pwid = str(102 + i) buf + ...

  7. hdu 1713求分数的最小公倍数

    题意中的圈数和天数说反了 #include<stdio.h> __int64 gcd(__int64 a,__int64 b) {/* 比如4/3 3/5 通分20/15 9/15 所以这 ...

  8. ExpressionTreeVisualizer

    看表达式的工具,这个工具后来微软不更新了,只支持到VS2013 表达式树的语法难度太大,语法和实现难度都大 相关文章 github地址

  9. Eclipse安装Jetty插件(Web容器)

    Eclipse除了安装Tomcat插件外,还可以安装Jetty,相对来说Jetty比Tomcat配置简单. Tomcat安装及配置:http://www.cnblogs.com/EasonJim/p/ ...

  10. 导致“mysql has gone away”的两种情况

    导致“mysql has gone away”的两种情况 By Cruise 1.  wait_timeout参数 在开发代理server时, 我使用了jdbc连接数据库,并采用长连接的方式连接数据库 ...