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. centos6.5 安装redis自动启动

    1.安装需要的支持环境 在安装Redis之前首要先做的是安装Unix的 Tcl工具 ,如果不安装的话后期将无法对Redis进行测试.在后期执行make test的时候返回如下错误信息: You nee ...

  2. eas之设定table选择模式

    tblMain.getSelectManager().setSelectMode(0);--不能选择  tblMain.getSelectManager().setSelectMode(1);--选择 ...

  3. Proc、宿主变量、指示变量、数组变量、通信区sqlca,oraca ---(day07)

    PROC 主要内容: ) proc简介 ) proc程序的开发过程 ) 宿主变量和指示变量 ) 嵌入sql语句 ) 连接数据库 ) 错误处理 ) 数据的存取更新操作 ) 动态sql --------- ...

  4. Noip 2013 练习

    转圈游戏 传送门 Solution 快速幂 Code //By Menteur_Hxy #include <cstdio> #include <cstdlib> #includ ...

  5. NFS实时备份

    方法一(inotify+rsync): 1.安装inotify-tools(客户端)[监听工具],实现数据属实备份检查目录是否有如下文档,没有表示操作系统不支持 ls -l /proc/sys/fs/ ...

  6. Python语言认识和实用工具(1)

    目录 1. Python语言概述 2. Python使用注意事项 3. Python学习工具 1. Python语言概述   Python是一种计算机程序设计语言.是一种动态的.面向对象的脚本语言,语 ...

  7. 2、Linux的关机方式

    shutdown 关机指令,你可以man shutdown 来看一下帮助文档.例如你可以运行如下命令关机: shutdown –h 10 ‘This server will shutdown afte ...

  8. 【ZOJ 4070】Function and Function

    [链接] 我是链接,点我呀:) [题意] [题解] 递归一会. 会发现最后肯定是0,1一直循环. 开始循环之后就直接返回结果就好. [代码] #include <bits/stdc++.h> ...

  9. 【Zoj 4061】Magic Multiplication

    [链接] 我是链接,点我呀:) [题意] [题解] /* for a[1] from 1~9 1*1=1 2*1=2 3*1=3 1*2=2 2*2=4 3*2=6 1*3=3 2*3=6 3*3=9 ...

  10. (21)Spring Boot过滤器、监听器【从零开始学Spring Boot】

    Spring Boot 系列博客] )前言[从零开始学Spring Boot] : http://412887952-qq-com.iteye.com/blog/2291496 )spring boo ...