What is a Memory Model?

Asked

Viewed 77 times

8

Reading the Wikipedia article in English discovered that Java was the first popular language to have a memory model in the presence of well-defined threads, followed by C++11.

Reading the article in question seems to me that the memory model defines rules and guarantees on how language should behave when multiple threads read and write on potentially shared variables. In particular, the Memory Model seems to define rules for the order of operations, as well as on the visibility of changes in shared memory. According to the article, the memory model opens space for optimizations that normally would not be possible in an environment multi-threaded.

Although I understood in a shallow way what a memory model is for, I didn’t really understand what it is. What kinds of rules are defined in a memory model? And how is this implemented in practice? (The article talks a lot about memory barriers and Fences which are also new concepts for me).

  • 2

    Part of my initiative to bring questions to the community

  • 2

    This article is very old, but excellent to understand even the question of immutable objects and the problem they cause in the JMM (Java Memory Model) https://www.ibm.com/developerworks/library/j-jtp02244/index.html

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.