Transparently Reconciling Transactions with Locking for Java Synchronization

Welc, Adam and Hosking, Antony L. and Jagannathan, Suresh


Concurrent data accesses in high-level languages like Java and C# are typically mediated using mutual-exclusion locks. Threads use locks to guard the operations performed while the lock is held, so that the lock’s guarded operations can never be interleaved with operations of other threads that are guarded by the same lock. This way both atomicity and isolation properties of a thread’s guarded operations are enforced. Recent proposals recognize that these properties can also be enforced by concurrency control protocols that avoid well-known problems associated with locking, by transplanting notions of transactions found in database systems to a programming language context. While higher-level than locks, software transactions incur significant implementation overhead. This overhead cannot be easily masked when there is little contention on the operations being guarded.

We show how mutual-exclusion locks and transactions can be reconciled transparently within Java’s monitor abstraction. We have implemented monitors for Java that execute using locks when contention is low and switch over to transactions when concurrent attempts to enter the monitor are detected. We formally argue the correctness of our solution with respect to Java’s execution semantics and provide a detailed performance evaluation for different workloads and varying levels of contention. We demonstrate that our implementation has low overheads in the uncontended case (7% on average) and that significant performance improvements (up to 3×) can be achieved from running contended monitors transactionally.

  author = {Welc, Adam and Hosking, Antony L. and Jagannathan, Suresh},
  title = {Transparently Reconciling Transactions with Locking for
                    {J}ava Synchronization},
  booktitle = {European Conference on Object-Oriented Programming},
  series = {ECOOP},
  volume = {4067},
  year = {2006},
  pages = {148--173},
  month = {July},
  location = {Nantes, France},
  doi = {10.1007/11785477_8},
  gscholar = {39}