Giter VIP home page Giter VIP logo

cplusplus-concurrency-in-practice's Issues

内存模型的一个问题

Hi, 我大概看了一下内存模型部分,整体来说写得不错,精神可佳,貌似你大多数部分是翻译的那本concurrency in action?有个地方貌似不太准确,请你参考。

例如,如果两个变量读写互不相关,编译器有可能将读操作提前(暂且称为预读prefetch 吧),或者尽可能延迟写操作,假设如下面的代码段:....

首先这里不能称为预读,这里编译器的优化其实是instruction reorder,是为了充分利用cpu的流水线结构,而将读写不相关的操作放到一起,这样cpu在等待一个数据从内存读过来(数千cpu周期)的时候,同时还能干别的,而不是干等着。预读是硬件的,和编译器没有太大关系。

其次,下面的这个例子。。。请问你是不是没有亲自编译看看?按照你写的这种reorder,结果都变了,这不可能的。。。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.