The Java memory model is fatally flawed

@article{Pugh2000TheJM,
  title={The Java memory model is fatally flawed},
  author={William W. Pugh},
  journal={Concurr. Pract. Exp.},
  year={2000},
  volume={12},
  pages={445-455}
}
  • W. Pugh
  • Published 1 May 2000
  • Computer Science
  • Concurr. Pract. Exp.
The Java memory model described in Chapter 17 of the Java Language Specification gives constraints on how threads interact through memory. This chapter is hard to interpret and poorly understood; it imposes constraints that prohibit common compiler optimizations and are expensive to implement on existing hardware. Most JVMs violate the constraints of the existing Java memory model; conforming to the existing specification would impose significant performance penalties. In addition… 

Figures from this paper

The Java memory model

The new Java model provides a simple interface for correctly synchronized programs -- it guarantees sequential consistency to data-race-free programs and could prove to be a useful basis for other programming languages that currently lack well-defined models, such as C++ and C#.

On Validity of Program Transformations in the Java Memory Model

This study analyzes the validity of several common program transformations in multi-threaded Java, and reveals some cases where the Sun Hotspot JVM does not comply with the Java Memory Model.

Requirements for Programming Language Memory Models

This paper outlines how the requirements for a new memory model were established, and what those requirements are, and does not outline the model itself; it merely provides a rationale.

A Java Compiler for Many Memory Models

  • S. Midkiff
  • Computer Science
    Java Virtual Machine Research and Technology Symposium
  • 2001
The approach the authors will discuss in this presentation, and in the remainder of this abstract, is radically different: Rather than having a xed memory model for the language, the memory model is allowed to be a property of a class.

The Java Memory Model: a Formal Explanation

This paper motivates the definition of the JMM, and shows the consequences of the wish to have the data race freeness guarantee and to forbid any out of thin air values to occur in an execution of multithreaded Java programs.

Making the java memory model safe

The model extends previous formalisations by dynamic memory allocation, thread spawns and joins, infinite executions, the wait-notify mechanism, and thread interruption, all of which interact in subtle ways with the memory model.

Semantics of Multithreaded Java

A new semantics for Java is proposed that addresses the issues raised by safety and multithreading, allows for aggressive compiler optimization and suggests solutions to some of the implementation issues.

Java and the Java Memory Model - A Unified, Machine-Checked Formalisation

The Java data race freedom guarantee for the complete formalisation in a modular way is proved and it is proved that the assumptions about the sequential semantics explicit and how to discharge them are made.

Concurrent Constraint-Based Memory Machines: A Framework for Java Memory Models

A simple, general framework for the specification of memory models based on an abstract machine that uses sets of order and value constraints to communicate between threads and main memory is presented and may be used as the basis for developing a formal memory model for the java programming language.

A Unified, Machine-Checked Formalisation of Java and the Java Memory Model

The Java data race freedom guarantee for the complete formalisation in a modular way is proved and it is proved that the assumptions about the sequential semantics explicit and how to discharge them are made.
...

References

SHOWING 1-10 OF 12 REFERENCES

From Sequential to Multi-Threaded Java: An Event-Based Operational Semantics

Event spaces are included in the operational judgements to develop the semantics of the full multi-threaded sublanguage of Java, which is shown to extend the one for sequential Java conservatively, allowing sequential programs to be reasoned about in a simplified computational framework without loss of generality.

The power of processor consistency

This work uses a formal model to give two distinct definitions of processors consistency: one corresponding to Goodman’s original proposal and the other corresponding that given by the implementors of the DASH system.

The Java Language Specification

The Java Language Specification, Second Edition is the definitive technical reference for the Java programming language and provides complete, accurate, and detailed coverage of the syntax and semantics of the Java language.

Formal Syntax and Semantics of Java

  • J. Alves-Foss
  • Computer Science
    Lecture Notes in Computer Science
  • 2002
This paper describes the Semantics of Java and proposes a Programmer Friendly Modular Definition of the Sem semantics of Java, as well as investigating the role of semantics in programming.

Java in practice : design styles and idioms for effective Java

This chapter discusses type safety and constants, as well as diagrams and coding conventions, and the design principles and tips used in the development of types for knowledge representation.

Detecting equality of variables in programs

An algorithm for detecting when two computations produce equivalent values by developing a static property called congruence, which is conservative in that any variables detected to be e:quivalent will in fact be equivalent, but not all equivalences are detected.

Global value numbers and redundant computations

This work proposes a redundancy elimination algorithm that is global (in that it deals with the entire program), yet able to recognize redundancy among expressions that are lexitally different, and takes advantage of second order effects.

Java consistency: nonoperational characterizations for Java memory behavior

This work provides a simpler definition of consistency model for Java, in which it is clearly distinguish the consistency model that is promised to the programmer from that which should be implemented in the JVM, and precisely defines their discrepancy.

Impact of ”reads kill” in java

  • http://www.cs.umd.edu/ ∼pugh/ java/readsKillImpact.html, May
  • 1999

Impact of " reads kill " in java

  • Impact of " reads kill " in java
  • 1999