Abstract
This paper describes the new Java memory model, which has been revised as part of Java 5.0. The model specifies the legal behaviors for a multithreaded program; it defines the semantics of multithreaded Java programs and partially determines legal implementations of Java virtual machines and compilers.The new Java model provides a simple interface for correctly synchronized programs -- it guarantees sequential consistency to data-race-free programs. Its novel contribution is requiring that the behavior of incorrectly synchronized programs be bounded by a well defined notion of causality. The causality requirement is strong enough to respect the safety and security properties of Java and weak enough to allow standard compiler and hardware optimizations. To our knowledge, other models are either too weak because they do not provide for sufficient safety/security, or are too strong because they rely on a strong notion of data and control dependences that precludes some standard compiler transformations.Although the majority of what is currently done in compilers is legal, the new model introduces significant differences, and clearly defines the boundaries of legal transformations. For example, the commonly accepted definition for control dependence is incorrect for Java, and transformations based on it may be invalid.In addition to providing the official memory model for Java, we believe the model described here could prove to be a useful basis for other programming languages that currently lack well-defined models, such as C++ and C#.
- Ada Joint Program Office. Ada 95 Rationale. Intermetrics, Inc., Cambridge, Massachusetts, 1995.]]Google Scholar
- Sarita Adve. Designing Memory Consistency Models for Shared-Memory Multiprocessors. PhD thesis, University of Wisconsin, Madison, December 1993. Ph.D. Thesis.]] Google ScholarDigital Library
- Sarita Adve and Kourosh Gharachorloo. Shared memory consistency models: A tutorial. IEEE Computer, 29(12):66--76, 1996.]] Google ScholarDigital Library
- Sarita Adve and Mark Hill. Weak ordering---A new definition. In Proc. of the 17th Annual Int'l Symp. on Computer Architecture (ISCA'90), pages 2--14, 1990.]] Google ScholarDigital Library
- Sarita V. Adve. The SC- memory model for Java, 2004. http://www.cs.uiuc.edu/~sadve/jmm.]]Google Scholar
- Sarita V. Adve and Mark D. Hill. A unified formalization of four shared-memory models. IEEE Trans. on Parallel and Distributed Systems, 4(6):613--624, June 1993.]] Google ScholarDigital Library
- Sarita V. Adve and Mark D. Hill. Sufficient conditions for implementing the data-race-free-1 memory model. Technical Report #1107, Computer Sciences Department, University of Wisconsin-Madison, September 1992.]]Google Scholar
- Arvind, Jan-Willem Maessen, and Xiaowei Shen. Improving the Java memory model using CRF. In OOPSLA, pages 1--12, October 2000.]] Google ScholarDigital Library
- John K. Bennett, John B. Carter, and Willy Zwanaepoel. Adaptive software cache management for distributed shared memory architectures. In Proc. 17th Annual Intl. Symp. on Computer Architecture, May 1990.]] Google ScholarDigital Library
- Gianfranco Bilardi and Keshav Pingali. A Framework for Generalized Control Dependence. In ACM SIGPLAN 1996 Conference on Programming Language Design and Implementation, Philadelphia, Pennsylvania, United States, June 1996.]] Google ScholarDigital Library
- Christopher Brumme. C# memory model. http://blogs.msdn.com/cbrumme/archive/2003/05/17/51445.apx.]]Google Scholar
- Michel Dubois, Christoph Scheurich, and Faye A. Briggs. Memory access buffering in multiprocessors. In Proc. 13th Ann. Intl. Symp. on Computer Architecture, pages 434--442, June 1986.]] Google ScholarDigital Library
- ECMA. Common Language Infrastructure (CLI), December 2002. http://www.ecma-international.org/publications/standards/Ecma-335.htm.]]Google Scholar
- Kourosh Gharachorloo. Memory consistency models for shared-memory multiprocessors. PhD thesis, Stanford University, 1996.]] Google ScholarDigital Library
- Kourosh Gharachorloo, Sarita V. Adve, Anoop Gupta, John L. Hennessy, and Mark D. Hill. Programming for different memory consistency models. Journal of Parallel and Distributed Computing, 15(4):399--407, August 1992.]]Google ScholarCross Ref
- Kourosh Gharachorloo, Anoop Gupta, and John Hennessy. Two techniques to enhance the performance of memory consistency models. In Proc. Intl. Conf. on Parallel Processing, pages I355--I364, 1991.]]Google Scholar
- Kourosh Gharachorloo, Daniel Lenoski, James Laudon, Phillip Gibbons, Anoop Gupta, and John Hennessy. Memory consistency and event ordering in scalable shared-memory multiprocessors. In Proc. 17th Ann. Intl. Symp. on Computer Architecture, pages 15--26, May 1990.]] Google ScholarDigital Library
- James Gosling, Bill Joy, and Guy Steele. The Java Language Specification. Addison Wesley, 1996.]] Google ScholarDigital Library
- IBM System/370 Principles of Operation, May 1983. Publication Number GA22-7000-9, File Number S370-01.]] Google ScholarDigital Library
- Java Specification Request (JSR) 133. Java Memory Model and Thread Specification Revision, 2004. http://jcp.org/jsr/detail/133.jsp.]]Google Scholar
- The Java memory model. Mailing list and web page. http://www.cs.umd.edu/users/pugh/java/memoryModel.]]Google Scholar
- Pete Keleher, Alan L. Cox, and Willy Zwaenepoel. Lazy release consistency for software distributed shared memory. In Proc. 19th Ann. Intl. Symp. on Computer Architecture, pages 13--21, 1992.]] Google ScholarDigital Library
- B. W. Kernighan and D. M. Ritchie. The C Programming Language. Prentice Hall, second edition, 1988.]] Google ScholarDigital Library
- Vishnu Kotrajaras. Towards an Improved Memory Model for Java. PhD thesis, Department of Computing, Imperial College, August 2001.]]Google Scholar
- Leslie Lamport. Time, clocks, and the ordering of events in a distributed system. CACM, 21(7):558--564, 1978.]] Google ScholarDigital Library
- Leslie Lamport. How to make a multiprocessor computer that correctly executes multiprocess programs. IEEE Transactions on Computers, 9(29):690--691, 1979.]]Google ScholarDigital Library
- Bil Lewis and Daniel J. Berg. Multithreaded programming with pthreads. Sun Microsystems, 2550 Garcia Avenue, Mountain View, CA 94043, USA, 1998.]] Google ScholarDigital Library
- Jeremy Manson and William Pugh. Core semantics of multithreaded Java. In ACM Java Grande Conference, June 2001.]] Google ScholarDigital Library
- Jeremy Manson and William Pugh. Semantics of Multithreaded Java. Technical Report CS-TR-4215, Dept. of Computer Science, University of Maryland, College Park, March 2001.]]Google Scholar
- Jeremy Manson and William Pugh. Requirements for Programming Language Memory Models. In PODC Workshop on Concurrency and Synchronization in Java Programs, St. John's, Newfoundland, Canada, July 2004.]]Google Scholar
- C. May et al., editors. The PowerPC Architecture: A Specification for a New Family of RISC Processors. Morgan Kaufmann, San Francisco, 1994.]] Google ScholarDigital Library
- Andy Podgurski and Lori Clarke. A formal model of program dependences and its implications for software testing debugging and maintenance. IEEE Transactions on Software Engineering, 1990.]] Google ScholarDigital Library
- William Pugh. Fixing the Java memory model. In ACM Java Grande Conference, June 1999.]] Google ScholarDigital Library
- William Pugh. The Java memory model is fatally flawed. Concurrency: Practice and Experience, 12(1):1--11, 2000.]]Google Scholar
- Parthasarathy Ranganathan, Vijay S. Pai, and Sarita V. Adve. Using speculative retirement and larger instruction windows to narrow the performance gap between memory consistency models. In Proceedings of the 9th Annual ACM Symposium on Parallel Algorithms and Architectures, pages 199--210, 1997.]] Google ScholarDigital Library
- Vijay Saraswat. Concurrent Constraint-based Memory Machines: A framework for Java Memory Models. Technical report, IBM TJ Watson Research Center, March 2004.]]Google Scholar
- Douglas Schmidt and Tim Harrison. Double-checked locking: An optimization pattern for efficiently initializing and accessing thread-safe objects. In 3rd Annual Pattern Languages of Program Design Conference, 1996.]] Google ScholarDigital Library
- Dennis Shasha and Marc Snir. Efficient and correct execution of parallel programs that share memory. ACM Trans. on Programming Languages and Systems, 10(2):282--312, April 1988.]] Google ScholarDigital Library
- Xiaowei Shen, Arvind, and Larry Rudolph. Commit-reconcile & fences (CRF): A new memory model for architects and compiler writers. Proceedings of the 26th International Symposium on Computer Archite cture, 1999.]] Google ScholarDigital Library
- R. L. Sites and R. T. Witek, editors. Alpha AXP Architecture Reference Manual. Digital Press, Boston, 1995. 2nd edition.]] Google ScholarDigital Library
- Bjarne Stroustrup. The C++ Programming Language. Addison-Wesley Longman, Reading Mass. USA, 3rd edition, 1997.]] Google ScholarDigital Library
- Z. Sura, C.-L. Wong, X. Fang, J. Lee, S. Midkiff, and D. Padua. Automatic implementation of programming language consistency models. In Proc. of the 15th International Workshop on Languages and Compilers for Parallel Computing (LCPC'02), 2002. To appear Lecture Notes in Computer Science, Springer-Verlag.]] Google ScholarDigital Library
- David Weaver and Tom Germond. The SPARC Architecture Manual, version 9. Prentice-Hall, 1994.]] Google ScholarDigital Library
- Yue Yang, Ganesh Gopalakrishnan, and Gary Lindstrom. Specifying Java thread semantics using a uniform memory model. In ACM Java Grande Conference, November 2001.]] Google ScholarDigital Library
- Yue Yang, Ganesh Gopalakrishnan, and Gary Lindstrom. Formalizing the Java memory model for multithreaded program correctness and optimization. Technical Report UUCS-02-011, University of Utah, April 2002.]]Google Scholar
Index Terms
- The Java memory model
Recommendations
The Java memory model
POPL '05: Proceedings of the 32nd ACM SIGPLAN-SIGACT symposium on Principles of programming languagesThis paper describes the new Java memory model, which has been revised as part of Java 5.0. The model specifies the legal behaviors for a multithreaded program; it defines the semantics of multithreaded Java programs and partially determines legal ...
JDMM: a java memory model for non-cache-coherent memory architectures
ISMM '14As the number of cores continuously grows, processor designers are considering non coherent memories as more scalable and energy efficient alternatives to the current coherent ones. The Java Memory Model (JMM) requires that all cores can access the Java ...
JDMM: a java memory model for non-cache-coherent memory architectures
ISMM '14: Proceedings of the 2014 international symposium on Memory managementAs the number of cores continuously grows, processor designers are considering non coherent memories as more scalable and energy efficient alternatives to the current coherent ones. The Java Memory Model (JMM) requires that all cores can access the Java ...
Comments