The Problem of Programming Language Concurrency Semantics

  • Mark Batty
  • Kayvan Memarian
  • Kyndylan Nienhuis
  • Jean Pichon-Pharabod
  • Peter Sewell
Part of the Lecture Notes in Computer Science book series (LNCS, volume 9032)


Despite decades of research, we do not have a satisfactory concurrency semantics for any general-purpose programming language that aims to support concurrent systems code. The Java Memory Model has been shown to be unsound with respect to standard compiler optimisations, while the C/C++11 model is too weak, admitting undesirable thin-air executions.

Our goal in this paper is to articulate this major open problem as clearly as is currently possible, showing how it arises from the combination of multiprocessor relaxed-memory behaviour and the desire to accommodate current compiler optimisations. We make several novel contributions that each shed some light on the problem, constraining the possible solutions and identifying new difficulties.

First we give a positive result, proving in HOL4 that the existing axiomatic model for C/C++11 guarantees sequentially consistent semantics for simple race-free programs that do not use low-level atomics (DRF-SC, one of the core design goals). We then describe the thin-air problem and show that it cannot be solved, without restricting current compiler optimisations, using any per-candidate-execution condition in the style of the C/C++11 model. Thin-air executions were thought to be confined to programs using relaxed atomics, but we further show that they recur when one attempts to integrate the concurrency model with more of C, mixing atomic and nonatomic accesses, and that also breaks the DRF-SC result. We then describe a semantics based on an explicit operational construction of out-of-order execution, giving the desired behaviour for thin-air examples but exposing further difficulties with accommodating existing compiler optimisations. Finally, we show that there are major difficulties integrating concurrency semantics with the C/C++ notion of undefined behaviour.

We hope thereby to stimulate and enable research on this key issue.


Memory Model Label Transition System Total Model Compiler Optimisation Concurrency Model 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


  1. 1.
    The SPARC architecture manual, v. 9,,
  2. 2.
    Programming Languages — C (2011), ISO/IEC 9899:2011,
  3. 3.
    Adve, S.V., Hill, M.D.: Weak ordering — a new definition. In: ISCA (1990)Google Scholar
  4. 4.
    Alglave, J., Maranget, L., Tautschnig, M.: Herding cats: Modelling, simulation, testing, and data mining for weak memory. ACM TOPLAS, 36(2) (2014)Google Scholar
  5. 5.
    Batty, M.: The C11 and C++11 concurrency model. PhD thesis, University of Cambridge (2014),
  6. 6.
    Batty, M., Dodds, M., Gotsman, A.: Library abstraction for C/C++ concurrency. In: Proc. POPL (2013)Google Scholar
  7. 7.
    Batty, M., Memarian, K., Owens, S., Sarkar, S., Sewell, P.: Clarifying and compiling C/C++ concurrency: from C++11 to POWER. In: Proc. POPL (2012)Google Scholar
  8. 8.
    Batty, M., Owens, S., Sarkar, S., Sewell, P., Weber, T.: Mathematizing C++ concurrency. In: Proc. POPL (2011)Google Scholar
  9. 9.
    Becker, P. (ed.): Programming Languages — C++ (2011), ISO/IEC 14882:2011,
  10. 10.
    Boehm, H.-J.: Threads cannot be implemented as a library. In: Proc. PLDI (2005)Google Scholar
  11. 11.
    Boehm, H.-J.: Memory model rationales (March 2007),
  12. 12.
    Boehm, H.-J.: N3786: Prohibiting “out of thin air” results in C++14 (September 2013),
  13. 13.
    Boehm, H.-J., Adve, S.V.: Foundations of the C++ concurrency memory model. In: Proc. PLDI (2008)Google Scholar
  14. 14.
    Boehm, H.-J., Demsky, B.: Outlawing ghosts: Avoiding out-of-thin-air results. In: Proc. MSPC (2014)Google Scholar
  15. 15.
    Boudol, G., Petri, G.: A theory of speculative computation. In: Gordon, A.D. (ed.) ESOP 2010. LNCS, vol. 6012, pp. 165–184. Springer, Heidelberg (2010)CrossRefGoogle Scholar
  16. 16.
    Cenciarelli, P., Knapp, A., Sibilio, E.: The Java memory model: Operationally, denotationally, axiomatically. In: De Nicola, R. (ed.) ESOP 2007. LNCS, vol. 4421, pp. 331–346. Springer, Heidelberg (2007)CrossRefGoogle Scholar
  17. 17.
    Demange, D., Laporte, V., Zhao, L., Jagannathan, S., Pichardie, D., Vitek, J.: Plan B: A buffered memory model for Java. In: POPL (2013)Google Scholar
  18. 18.
    Free Software Foundation, Inc., RTL Passes — GNU Compiler Collection (GCC) Internals (October 2014),
  19. 19.
    Gharachorloo, K., Adve, S.V., Gupta, A., Hennessy, J.L., Hill, M.D.: Programming for different memory consistency models. Journal of Parallel and Distributed Computing 15, 399–407 (1992)CrossRefGoogle Scholar
  20. 20.
    Gosling, J., Joy, B., Steele, G.: The Java Language Specification (1996)Google Scholar
  21. 21.
    The HOL 4 system,
  22. 22.
    Jagadeesan, R., Pitcher, C., Riely, J.: Generative operational semantics for relaxed memory models. In: Gordon, A.D. (ed.) ESOP 2010. LNCS, vol. 6012, pp. 307–326. Springer, Heidelberg (2010)CrossRefGoogle Scholar
  23. 23.
    Lamport, L.: How to make a multiprocessor computer that correctly executes multiprocess programs. IEEE Trans. Comput. C-28(9), 690–691 (1979)CrossRefGoogle Scholar
  24. 24.
    LLVM Project. LLVM’s Analysis and Transform Passes — LLVM 3.6 documentation (October 2014),
  25. 25.
    Manson, J., Pugh, W., Adve, S.V.: The Java memory model. In: POPL (2005)Google Scholar
  26. 26.
    Maranget, L., Sarkar, S., Sewell, P.: A tutorial introduction to the ARM and POWER relaxed memory models (October 2012),
  27. 27.
    Marino, D., Singh, A., Millstein, T., Musuvathi, M., Narayanasamy, S.: A case for an SC-preserving compiler. In: PLDI (2011)Google Scholar
  28. 28.
    McKenney, P.: Reordering and verification at the linux kernel reorder workshop in vienna summer of logic. In: Invited talk at REORDER Workshop, Vienna Summer of Logic (July 2014),
  29. 29.
    Morisset, F.R., Pawan, P., Nardelli, Z.: Compiler testing via a theory of sound optimisations in the C11/C++11 memory model. In: Proc. PLDI (2013)Google Scholar
  30. 30.
    Norris, B., Demsky, B.: CDSchecker: Checking concurrent data structures written with C/C++ atomics. In: Proc. OOPSLA (2013)Google Scholar
  31. 31.
    Pugh, W.: Fixing the Java memory model. In: Proc. ACM 1999 Conference on Java Grande (1999)Google Scholar
  32. 32.
    Sarkar, S., Memarian, K., Owens, S., Batty, M., Sewell, P., Maranget, L., Alglave, J., Williams, D.: Synchronising C/C++ and POWER. In: Proc. PLDI (2012)Google Scholar
  33. 33.
    Sarkar, S., Sewell, P., Alglave, J., Maranget, L., Williams, D.: Understanding POWER multiprocessors. In: Proc. PLDI (2011)Google Scholar
  34. 34.
    Ševčík, J., Aspinall, D.: On Validity of Program Transformations in the Java Memory Model. In: Vitek, J. (ed.) ECOOP 2008. LNCS, vol. 5142, pp. 27–51. Springer, Heidelberg (2008)CrossRefGoogle Scholar
  35. 35.
    Sewell, P., Sarkar, S., Owens, S., Zappa Nardelli, F., Myreen, M.O.: x86-TSO: A rigorous and usable programmer’s model for x86 multiprocessors. C. ACM 53(7), 89–97 (2010), (Research Highlights) Google Scholar
  36. 36.
    Singh, A., Narayanasamy, S., Marino, D., Millstein, T., Musuvathi, M.: End-to-end sequential consistency. In: Proc. ISCA (2012)Google Scholar
  37. 37.
    Turon, A., Vafeiadis, V., Dreyer, D.: GPS: Navigating weak memory with ghosts, protocols, and separation. In: Proc. OOPSLA (2014)Google Scholar
  38. 38.
    Vafeiadis, V., Balabonski, T., Chakraborty, S., Morisset, R., Zappa Nardelli, F.: Common compiler optimisations are invalid in the C11 memory model and what we can do about it. In: Proc. POPL (2015)Google Scholar
  39. 39.
    Vafeiadis, V., Narayan, C.: Relaxed separation logic: A program logic for C11 concurrency. In: Proc. OOPSLA (2013)Google Scholar
  40. 40.
    Ševčík, J.: Safe optimisations for shared-memory concurrent programs. In: PLDI (2011)Google Scholar
  41. 41.
    Ševčík, J., Vafeiadis, V., Zappa Nardelli, F., Jagannathan, S., Sewell, P.: CompCertTSO: A verified compiler for relaxed-memory concurrency. J. ACM 60, 22:1–22:50 (2013)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2015

Authors and Affiliations

  • Mark Batty
    • 1
  • Kayvan Memarian
    • 1
  • Kyndylan Nienhuis
    • 1
  • Jean Pichon-Pharabod
    • 1
  • Peter Sewell
    • 1
  1. 1.University of CambridgeCambridgeUK

Personalised recommendations