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. 【VIP视频网站项目二】搭建爱奇艺优酷腾讯视频官网首页轮播图效果及实现原理分析

    这个是实现的效果,基本上轮播效果和主流网站的一致,但是我也在上面优化了一些效果, 可以在线预览效果:https://vip.52tech.tech/ 目前项目代码已经全部开源:项目地址:https:/ ...

  2. nyoj22-素数求和问题

    素数求和问题 时间限制:3000 ms  |  内存限制:65535 KB 难度:2 描述 现在给你N个数(0<N<1000),现在要求你写出一个程序,找出这N个数中的所有素数,并求和. ...

  3. 解决@vue/cli 创建项目是安装chromedriver时失败的问题

    最近在使用新版vue的命令行工具创建项目时,安装chromedriver老是失败,导致后面的步骤也没有进行.网上搜索了一下,全是使用 工作中常见问题汇总及解决方案 npm install chrome ...

  4. vue全局使用axios的方法

    在vue项目开发中,我们使用axios的二次封装,很多人一开始使用axios的方式,会当成vue-resoure的使用方式来用,即在主入口文件引入import VueResource from 'vu ...

  5. 【习题 4-6 UVA - 508】Morse Mismatches

    [链接] 我是链接,点我呀:) [题意] 给你每个字母对应的摩斯密码. 然后每个单词的莫斯密码由其组成字母的莫斯密码连接而成. 现在给你若干个莫斯密码. 请问你每个莫斯密码对应哪个单词. 如果有多个单 ...

  6. @requestbody @responsebody详解

    @requestbody @responsebody详解 会唤起spring mvc的httpmessageconveter转换类进行数据转换 简介: @RequestBody 作用: i) 该注解用 ...

  7. hdu 2883 kebab(时间区间压缩 &amp;&amp; dinic)

    kebab Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Subm ...

  8. 用SecureCRT在linux系统下载文件

    使用sz命令 说明如下: sz --helpsz version 0.12.20Usage: sz [options] file ...   or: sz [options] -{c|i} COMMA ...

  9. mysql5.7下面windows平台大小写敏感

    转自:https://blog.csdn.net/lrl219/article/details/52889582 根据网上的信息在my.ini下面的mysqld的配置下面添加lower_case_ta ...

  10. LINUX/UNIX找回删除的文件

    当Linux计算机受到入侵时,常见的情况是日志文件被删除,以掩盖攻击者的踪迹.管理错误也可能导致意外删除重要的文件,比如在清理旧日志时,意外地删除了数据库的活动事务日志.有时可以通过lsof来恢复这些 ...