PDF
(1506KB)
Abstract
Happens-before memory model (HMM) is used as the basis of Java memory model (JMM). Although HMM itself is simple, some complex axioms have to be introduced in JMM to prevent the causality loop, which causes absurd out-of-thin-air reads that may break the type safety and security guarantee of Java. The resulting JMM is complex and difficult to understand. It also has many anti-intuitive behaviors, as demonstrated by the “ugly examples” by Aspinall and Ševˇcík [1]. Furthermore, HMM (and JMM) specifies only what execution traces are acceptable, but says nothing about how these traces are generated. This gap makes it difficult for static reasoning about programs.
In this paper we present OHMM, an operational variation of HMM. The model is specified by giving an operational semantics to a language running on an abstract machine designed to simulate HMM. Thanks to its generative nature, the model naturally prevents out-of-thin-air reads. On the other hand, it uses a novel replay mechanism to allow instructions to be executed multiple times, which can be used to modelmany useful speculations and optimization. The model is weaker than JMM for lockless programs, thus can accommodate more optimization, such as the reordering of independent memory accesses that is not valid in JMM. Program behaviors are more natural in this model than in JMM, and many of the anti-intuitive examples in JMM are no longer valid here. We hope OHMM can serve as the basis for new memory models for Java-like languages.
Keywords
relaxed memory model
/
happens-before
/
operatonal semantics
/
DRF-Guarantee
/
JMM
Cite this article
Download citation ▾
Yang ZHANG, Xinyu FENG.
An operational happens-before memory model.
Front. Comput. Sci., 2016, 10(1): 54-81 DOI:10.1007/s11704-015-4492-4
| [1] |
Aspinall D, Ševˇcík J. Java memory model examples: good, bad and ugly. In: Proceedings of Verification and Analysis of Multi-threaded Java-like Programs. 2007, 66–80
|
| [2] |
Lamport L. How to make a multiprocessor computer that correctly executes multiprocess programs. IEEE Transactions on Computers, 1979, 28(9): 690–691
|
| [3] |
Boehm H J. Threads cannot be implemented as a library. In: Proceedings of Programming Language Design and Implementation. 2005, 261–268
|
| [4] |
Adve S V, Gharachorloo K. Shared memory consistency models: a tutorial. IEEE Transactions on Computers, 1996, 29(12): 66–76
|
| [5] |
Manson J, Pugh W, Adve S V. The Java memory model. In: Proceedings of the 32nd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. 2005, 378–391
|
| [6] |
Cenciarelli P, Knapp A, Sibilio E. The Java memory model: operationally, denotationally, axiomatically. In: Proceedings of the 16th European Symposium on Programming. 2007, 331–346
|
| [7] |
Zhang Y, Feng X. An operational approach to happens-before memory model. In: Proceedings of the 7th International Symposium on Theoretical Aspects of Software Engineering. 2013, 121–128
|
| [8] |
Lamport L. Time, clocks, and the ordering of events in a distributed system. Communications of the ACM, 1978, 21(7): 558–565
|
| [9] |
Aspinall D, Ševˇcík J. Formalising Java’s data race free guarantee. In: Proceedings of Theorem Proving in Higher Order Logics. 2007, 22–37
|
| [10] |
Huisman M, Petri G. The Java memory model: a formal explanation. In: Proceedings of Verification and Analysis of Multi-threaded Javalike Programs. 2007, 81–96
|
| [11] |
Manson J. The Java Memory Model. Dissertation for the Doctoral Degree. College Park: University of Maryland, 2004
|
| [12] |
Ševˇcík J, Aspinall D. On validity of program transformations in the Java memory model. In: Proceedings of the 22nd European Conference on Object-Oriented Programming. 2008, 27–51
|
| [13] |
Vafeiadis V, Balabonski T, Chakraborty S, Morisset R, Nardelli F Z. Common compiler optimisations are invalid in the C11 memory model and what we can do about it. In: Proceedings of the 42nd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. 2015, 209–220
|
| [14] |
Yang Y, Gopalakrishnan G, Lindstrom G. Specifying Java thread semantics using a uniform memory model. In: Proceedings of Joint ACM Java Grande- ISCOPE 2002 Conference. 2002, 192–201
|
| [15] |
Lochbihler A. Java and the Java memory model- a unified, machinechecked formalisation. In: Proceedings of the 21st European Symposium on Programming. 2012, 497–517
|
| [16] |
Saraswat V A, Jagadeesan R, Michael M M, Praun V C. A theory of memory models. In: Proceedings of the 12th ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming. 2007, 161–172
|
| [17] |
Jagadeesan R, Pitcher C, Riely J. Generative operational semantics for relaxed memory models. In: Proceedings of the 19th European Symposium on Programming. 2010, 307–326
|
| [18] |
Sarkar S, Sewell P, Alglave J, Maranget L,Williams D. Understanding power multiprocessors. In: Proceedings of the 32nd ACM SIGPLAN Conference on Programming Language Design and Implementation. 2011, 175–186
|
RIGHTS & PERMISSIONS
Higher Education Press and Springer-Verlag Berlin Heidelberg
PDF
(1506KB)