Memory model (computing)

Memory model (computing)

In computing, a memory model describes the interactions of threads through memory and specifies the assumptions the compiler is allowed to make when generating code for segmented memory or paged memory platforms.

History and significance

A memory model allows a compiler to perform many important optimizations. Even simple compiler optimizations like loop fusion move statements in the program and influence the order of read and write operations of potentially shared variables. Changes in the ordering of reads and writes can cause race conditions. Without a memory model, a compiler is not allowed to apply such optimizations to multi-threaded programs in general, or only in special cases.

Modern programming languages like Java therefore implement a memory model. The memory model specifies synchronization barriers that are established via special, well-defined synchronization operations such as acquiring a lock by entering a synchronized block or method. The memory model stipulates that changes to the values of shared variables only need to be made visible to other threads when such a synchronization barrier is reached. Moreover, the entire notion of a Race condition is entirely defined over the order of operations with respect to these memory barriers.[1]

These semantics then give optimizing compilers a higher degree of freedom when applying optimizations: the compiler needs to make sure only that the values of (potentially shared) variables at synchronization barriers are guaranteed to be the same in both the optimized and unoptimized code. In particular, reordering statements in a block of code that contains no synchronization barrier is assumed to be safe by the compiler.

Most research in the area of memory models revolves around:

  • Designing a memory model that allows a maximal degree of freedom for compiler optimizations while still giving sufficient guarantees about race-free and (perhaps more importantly) race-containing programs.
  • Proving program optimizations that are correct with respect to such a memory model.

The Java memory model was the first attempt to provide a comprehensive threading memory model for a popular programming language.[2] Since then, the need for a memory model has been more widely accepted, and efforts are underway to provide such semantics for languages like C++0x, the next version of C++.[3][4]

See also

References

  1. ^ Jeremy Manson and Brian Goetz (February 2004). "JSR 133 (Java Memory Model) FAQ". http://www.cs.umd.edu/~pugh/java/memoryModel/jsr-133-faq.html. Retrieved 2010-10-18. "The Java Memory Model describes what behaviors are legal in multithreaded code, and how threads may interact through memory. It describes the relationship between variables in a program and the low-level details of storing and retrieving them to and from memory or registers in a real computer system. It does this in a way that can be implemented correctly using a wide variety of hardware and a wide variety of compiler optimizations." 
  2. ^ Goetz, Brian (2004-02-24). "Fixing the Java Memory Model, Part 1". http://www.ibm.com/developerworks/library/j-jtp02244.html. Retrieved 2008-02-17. 
  3. ^ Boehm, Hans (2005-03-04). "Memory Model for Multthreaded C++". http://www.scribd.com/doc/7325516/Memory-Model-for-Multthreaded-C. Retrieved 2008-02-17. 
  4. ^ Boehm, Hans. "Threads and memory model for C++". http://www.hpl.hp.com/personal/Hans_Boehm/c++mm/. Retrieved 2008-02-17. 

Wikimedia Foundation. 2010.

Игры ⚽ Поможем решить контрольную работу

Look at other dictionaries:

  • Memory model — may refer to: Psychology Atkinson–Shiffrin memory model Baddeley s model of working memory Memory prediction model Informatics In computer software, a memory model describes how threads interact through memory, or what assumptions the compiler… …   Wikipedia

  • C memory model — Memory models in the C programming language are a way to specify assumptions that the compiler should make when generating code for segmented memory or paged memory platforms.For example, on the 16 bit x86 platform, six memory models exist. They… …   Wikipedia

  • Flat memory model — In computer systems design, a flat memory model refers to a linear addressing paradigm, such that the CPU can directly (and sequentially) address all of the available memory locations, without having to resort to any sort of bank switching or… …   Wikipedia

  • Java Memory Model — The Java memory model describes how threads in the Java programming language interact through memory. Together with the description of single threaded execution of code, the memory model provides the semantics of the Java programming language.… …   Wikipedia

  • Intel Memory Model — The Intel x86 cpu has six memory models which control how the segment registers are used and the default size of pointers. Contents 1 Memory segmentation 2 Pointer sizes 3 Memory models 4 …   Wikipedia

  • Memory barrier — Memory barrier, also known as membar or memory fence or fence instruction, is a type of barrier and a class of instruction which causes a central processing unit (CPU) or compiler to enforce an ordering constraint on memory operations issued… …   Wikipedia

  • Memory ordering — is a group of properties of the modern microprocessors, characterising their possibilities in memory operations reordering. It is a type of out of order execution. Memory reordering can be used to fully utilize different cache and memory banks.… …   Wikipedia

  • Computing with Memory — refers to computing platforms where function response is stored in memory array, either one or two dimensional, in the form of lookup tables (LUTs) and functions are evaluated by retrieving the values from the LUTs. These computing platforms can… …   Wikipedia

  • Memory coherence — is an issue that affects the design of computer systems in which two or more processors or cores share a common area of memory.[1][2][3][4] In a uniprocessor system (whereby, in today s terms, there exists only one core), there is only one… …   Wikipedia

  • Memory architecture — describes the methods used to implement electronic computer data storage in a manner that is a combination of the fastest, most reliable, most durable, and least expensive way to store and retrieve information. Depending on the specific… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”