A Domain Specific Language for Composable Memory Transactions in Java

  • André Rauber Du Bois
  • Marcos Echevarria
Part of the Lecture Notes in Computer Science book series (LNCS, volume 5658)


In this paper we present CMTJava, a domain specific language for composable memory transactions [7] in Java. CMTJava provides the abstraction of transactional objects. Transactional objects have their fields accessed only by special get and set methods that are automatically generated by the compiler. These methods return transactional actions as a result. A transactional action is an action that, when executed, will produce the desired effect. Transactional actions can only be executed by the atomic method. Transactional actions are first class values in Java and they are composable: transactions can be combined to generate new transactions. The Java type system guarantees that the fields of transactional objects will never be accessed outside a transaction. CMTJava supports the retry and orElse constructs from STM Haskell. To validate our design we implemented a simple transactional system following the description of the original Haskell system. CMTJava is implemented as a state passing monad using BBGA closures, a Java extension that supports closures in Java.


Transactional Action Transactional Memory Translation Rule Software Transactional Memory Memory Transaction 
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.
    All About Monads. WWW page (December 2008),
  2. 2.
    Java Closures. WWW page (December 2008),
  3. 3.
    JSR Proposal: Closures for Java. WWW page (December 2008),
  4. 4.
    Carlstrom, B.D., McDonald, A., Chafi, H., Chung, J., Minh, C.C., Kozyrakis, C., Olukotun, K.: The ATOMOS transactional programming language. ACM SIGPLAN Notices 41(6), 1–13 (2006)CrossRefzbMATHGoogle Scholar
  5. 5.
    Hammond, L., Wong, V., Chen, M., Carlstrom, B.D., Davis, J.D., Hertzberg, B., Prabhu, M.K., Wijaya, H., Kozyrakis, C., Olukotun, K.: Transactional memory coherence and consistency, New York, NY, USA, vol. 32, p. 102. ACM, New York (2004)Google Scholar
  6. 6.
    Harris, T., Fraser, K.: Language support for lightweight transactions. ACM SIGPLAN Notices 38(11), 388–402 (2003)CrossRefGoogle Scholar
  7. 7.
    Harris, T., Marlow, S., Peyton Jones, S., Herlihy, M.: Composable memory transactions. In: PPoPP 2005. ACM Press, New York (2005)Google Scholar
  8. 8.
    Herlihy, M., Luchangco, V., Moir, M.: A flexible framework for implementing software transactional memory. SPNOTICES: ACM SIGPLAN Notices 41 (2006)Google Scholar
  9. 9.
    Herlihy, M., Luchangco, V., Moir, M., Scherer III, W.N.: Software transactional memory for dynamic-sized data structures. In: PODC: 22th ACM SIGACT-SIGOPS Symposium on Principles of Distributed Computing (2003)Google Scholar
  10. 10.
    Herlihy, M., Moss, J.E.B.: Transactional memory: Architectural support for lock-free data structures. In: Proceedings of the Twentieth Annual International Symposium on Computer Architecture (1993)Google Scholar
  11. 11.
    Hoare, C.A.R.: Towards a theory of parallel programming. Operating System Techniques, 61–71 (1972)Google Scholar
  12. 12.
    Huch, F., Kupke, F.: A high-level implementation of composable memory transactions in concurrent haskell. In: Butterfield, A., Grelck, C., Huch, F. (eds.) IFL 2005. LNCS, vol. 4015, pp. 124–141. Springer, Heidelberg (2006)CrossRefGoogle Scholar
  13. 13.
    Hutton, G., Meijer, E.: Monadic Parsing in Haskell. Journal of Functional Programming 8(4), 437–444 (1998)CrossRefzbMATHGoogle Scholar
  14. 14.
    Igarashi, A., Pierce, B., Wadler, P.: Featherweight Java: A minimal core calculus for Java and GJ. TOPLAS 23(3), 396–459 (2001)CrossRefGoogle Scholar
  15. 15.
    Larus, J., Rajwar, R.: Transactional Memory. Morgan & Claypool (2006)Google Scholar
  16. 16.
    Lee, E.A.: The problem with threads. IEEE Computer 39(5), 33–42 (2006)CrossRefGoogle Scholar
  17. 17.
    Marathe, V.J., Spear, M.F., Heriot, C., Acharya, A., Eisenstat, D., Scherer III, W.N., Scott, M.L.: Lowering the overhead of nonblocking software transactional memory. revised, University of Rochester, Computer Science Department (May 2006)Google Scholar
  18. 18.
    McDonald, A., Chung, J., Chafi, H., Minh, C.C., Carlstrom, B.D., Hammond, L., Kozyrakis, C., Olukotun, K.: Characterization of TCC on chip-multiprocessors. In: Proc. 14th International Conference on Parallel Architecture and Compilation Techniques (14th PACT 2005), pp. 63–74. IEEE Computer Society, Los Alamitos (2005)Google Scholar
  19. 19.
    Peterson, J., Hudak, P., Elliott, C.: Lambda in motion: Controlling robots with haskell. In: Gupta, G. (ed.) PADL 1999. LNCS, vol. 1551, pp. 91–105. Springer, Heidelberg (1999)CrossRefGoogle Scholar
  20. 20.
    Peyton Jones, S.: Tackling the awkward squad: monadic input/output, concurrency, exceptions, and foreign-language calls in Haskell. In: Engineering theories of software construction, pp. 47–96. IOS Press, Amsterdam (2001)Google Scholar
  21. 21.
    Peyton Jones, S.: Haskell 98 language and libraries: the revised report. Journal of Functional Programming 1(13) (2003)Google Scholar
  22. 22.
    Peyton Jones, S.: Beautiful Concurrency. O’Reilly, Sebastopol (2007)Google Scholar
  23. 23.
    Rajwar, R., Herlihy, M., Lai, K.K.: Virtualizing transactional memory. In: ISCA, pp. 494–505. IEEE Computer Society, Los Alamitos (2005)Google Scholar
  24. 24.
    Rajwar, R., James, G.: Transactional execution: Toward reliable, high-performance multithreading. IEEE Micro. 23(6), 117–125 (2003)CrossRefGoogle Scholar
  25. 25.
    Shavit, N., Touitou, D.: Software transactional memory. DISTCOMP: Distributed Computing, 10 (1997)Google Scholar

Copyright information

© IFIP International Federation for Information Processing 2009

Authors and Affiliations

  • André Rauber Du Bois
    • 1
  • Marcos Echevarria
    • 1
  1. 1.PPGInf - Programa de Pós-Graduação em InformáticaUniversidade Católica de PelotasPelotas-RSBrazil

Personalised recommendations