Memory Model
The following five references give you an introduction on out-of-order execution on modern CPUs:
[1] [2] [3] [4] [5] This reference tells you the current memory model development in Java and other mainstream languages:[6] This reference tells you how mainstream processors handle out-of-order memory references:[7] This reference tells you an important compiler reorder mechanism:[8] The following four references tell you everything about Java memory model (JMM) JSR-133:[9] [10] [11] [12] This reference introduces you some of Sun’s current JIT compiler optimizations:[13] The following two references introduce you Java thread executor and fork-join frameworks:[14] [15] This reference introduces you distributed computing by actor model:[16]C# - The C# Memory Model in Theory and Practice
What Every Multithread eDde Av pMpusst
Understand the Impact of Low-Lock Techniques in Multithreaded Apps
re 1: check out this document:
re 2: this is covered in the JVM Specification, Chapter 3:
re 3: not sure what you are asking, but it sounds like Chapter 5 of the VM spec is what you are looking for:
You probably want to read the whole VM spec actually:
, Intel, Microsoft Research, Univ. of Rochester, Microsoft Research
The Java Memory Model
This web page is a starting point for discussions of and information concerning the Java Memory Model ( of the ). The Java Memory Model defines how threads interact through memory. It used to be somewhat unclear and unnecessarily limiting, and so was revised. This is a reference page for that revision. The official site for JSR 133 - The Java(tm) Memory Model and Thread Specification Revision - .
This page is divded up into several sections:
- on the memory model.
- .
- .
- on the memory model, now obsolete.
- from other sources.
Reference Material
These reference materials are a good starting point for anyone trying to understand the memory model. Between them, they cover most of the major issues involved.
- For First-Time Visitors
- A is available. This is a good place to start for those just becoming aware of the issues. (February 11, 2004)
- For JVM and compiler implementors
- , which is a guide for compiler writers who wish to implement the Java memory model.
- Sarita Adve and Kourosh Gharachorloo wrote a tutorial on memory models in 1995 that remains an excellent reference and primer. Compaq Research Report 95/7, September 1995, .
- For those wishing to understand the memory model in full
- about the memory model that combines Jeremy Manson's dissertation, the POPL paper and the CSJP paper. For those interested in a thorough discussion of the memory model issues, this is the best bet. (October 7, 2005).
- . This is the "official specification" (August 9, 2004). It doesn't contain much in the way of explanation.
- . This is a brief description of the semantics of final fields. (May 12, 2004)
Mailing list
- To join the Java memory model mailing list, visit .
- To post to the list, email (only subscribers may post to the list).
- The list has migrated. To access the archive of the old list, visit . To access the archive of the new list, visit .
Additional Information
Double-Checked Locking is Broken
Double-checked locking (also known as the multithreaded singleton pattern) is a widely employed idiom for publishing a singleton object to multiple threads.
- The "Double-Checked Locking is Broken" Declaration
describes why the double-checked locking pattern is broken unless you use explicit memory barriers (or make assumptions about your processor and compiler).
- Descriptions of double-check idiom
- , Douglas C. Schmidt, C++ Report, SIGS, Vol. 8, No. 3, March 1996.
- , Douglas Schmidt and Tim Harrison. 3rd annual Pattern Languages of Program Design conference, 1996
- , Philip Bishop and Nigel Warren, JavaWorld Magazine
- , Allen Holub, Javaworld Magazine, April 1999.
Other information
- Informal notes we made about legal and illegal multithreaded patterns are available in .
- Volatile spec compliance tests
- - Tests for atomic read/writes of volatile Longs
- - Tests for illegal compiler optimizations involving volatiles
- - Tests for sequential consistency of volatiles
- is a tar file containing the tests and more detail about their output.
Older Material (for the memory model historians among you)
This is a list of many of the revisions that the memory model underwent over the course of its three years in flight. They are mostly out of date. If you are interested in the model as it stands, your best bet is the reference material .
Draft Proposals for the Memory Model
- (April 23, 2004)
- (April 12, 2004)
- (March 16, 2004)
- , includes clarifications and minor fixes, does not incorporate a new formalism. (March 16, 2004)
- (March 16, 2004)
- (March 16, 2004)
- (February 24, 2004).
- (February 2, 2004).
- The competing models of February 6, 2004.
- Manson/Pugh model:
- Manson/Pugh model:
- October 17, 2003
- August 29, 2003:
- August 8, 2003:
- August 4, 2003:
- July 31, 2003:
- The full semantics of normal fields are in , by Jeremy Manson and William Pugh, Revised Jan 13, 2003.
- The full semantics of final fields are in , by Jeremy Manson and William Pugh, Revised April 7, 2003.
- , a previous version of the semantics. (2001)
- Weak Memory Orders and Object Oriented Programming, draft of the abstract for an OOPSLA poster session submission () ()
- by , Journal version of the following paper; cleans up the paper somewhat and removes the naive fixes suggested in that paper.
- by ,
Talks
- (October 24th, 2003)
- Multithreaded semantics for Java, (edited version of presentation given at MIT Sept 10th, 2000) Slides ( or ) and handout ( or )
Additional Background Reading
By Doug Lea
- , Section 2.2.7 of , Doug Lea, Addison Wesley, 1999
- , Doug Lea
By Cenciarelli et al
- , P. Cenciarelli, A. Knapp, B. Reus, M. Wirsing, In Jim Alves-Foss (Ed.) Formal Syntax and Semantics Of Java, LNCS 1523, pp. 157--200, Springer, Berlin, 1999.
- , P. Cenciarelli, A. Knapp, B. Reus, M. Wirsing, In Proc. 6^th Int. Conf. Algebraic Methodology and Software Technology, LNCS 1376, pp. 402--417. Springer Verlag. Berlin 1998.
- , B. Reus, A. Knapp, P. Cenciarelli, M. Wirsing, WADT Workshop 97, LNCS.
By Schuster et al.
- by , Workshop on Java for High-Performance Computing, June 1999, Rhodes.
- by Alex Gontmakher and Assaf Schuster, ACM Transactions on Computer Systems Volume 18 , No. 4 (Nov. 2000) Pages 333 - 386.
On other memory models
- (148K gzipped Postscript), "Location Consistency -- a new Memory Model and Cache Consistency Protocol," Guang R. Gao, Vivek Sarkar, February 16, 1998.
- , Lamport et al.
By Arvind et al.
- , Jan-Willem Maessen, Arvind, and Xiaowei Shen, OOPSLA 2000
- , Xiaowei Shen, Arvind and Larry Rudolph, December 1998, To appear in proceedings of the 26th International Symposium on Computer Architecture, May 1999, Atlanta, Georgia., (14 pages).
- , Jan-Willem Maessen, Arvind, and Xiaowei Shen, OOPSLA 2000
By others
- by , Digital Western Research Laboratories
- : JLS requires Coherence, Sun's JIT doesn't provide it.
- , Yuri Gurevich, Wolfram Schulte and