Condition Variables and Transactional Memory : Problem or Opportunity ?

Condition variables complement locks by allowing a program to specify the order of execution. They have been in use, largely unchanged, for three decades and have proved to be a robust and scalable synchronization mechanism. However, most transactional memory (TM) systems provide no complementary mechanism. While new synchronization constructs have been proposed for TM, it seems prudent to support condition variables with transactional memory at least until other proposals prove themselves to be as robust and enduring. We present an examination of condition variables and transactional memory. We show that straightforward conversion of lock-based condition variable mechanisms to transactions may be incorrect for some TM systems. We present two condition variable designs for transactional memory that require little from the underlying TM system yet can express common usages of conditional waiting. Both versions impose minimal requirements on the TM system and neither requires knowledge of how TM is implemented or modifications to the TM system. To adapt condition variables to transactions, we split the wait operation into two operations, preparing to wait transactionally and completing the wait after commit. In the first design, we defer signaling until after commit to prevent races between signalers and the waiters they wake up. In the second, we signal speculatively before the transaction commits and depend on transactional conflict detection to prevent races. We show that both perform well on lock-based programs from the PARSEC suite converted to transactions.

[1]  Yuanyuan Zhou,et al.  Learning from mistakes: a comprehensive study on real world concurrency bug characteristics , 2008, ASPLOS.

[2]  Adam Welc,et al.  Design and implementation of transactional constructs for C/C++ , 2008, OOPSLA '08.

[3]  Suresh Jagannathan,et al.  Transactional Monitors for Concurrent Objects , 2004, ECOOP.

[4]  Kai Li,et al.  The PARSEC benchmark suite: Characterization and architectural implications , 2008, 2008 International Conference on Parallel Architectures and Compilation Techniques (PACT).

[5]  Kunle Olukotun,et al.  The Atomos transactional programming language , 2006, PLDI '06.

[6]  David A. Wood,et al.  Supporting nested transactional memory in logTM , 2006, ASPLOS XII.

[7]  David A. Wood,et al.  LogTM-SE: Decoupling Hardware Transactional Memory from Caches , 2007, 2007 IEEE 13th International Symposium on High Performance Computer Architecture.

[8]  Ravi Rajwar,et al.  Speculative lock elision: enabling highly concurrent multithreaded execution , 2001, Proceedings. 34th ACM/IEEE International Symposium on Microarchitecture. MICRO-34.

[9]  Andrew D. Birrell,et al.  Implementing Condition Variables with Semaphores , 2004 .

[10]  Guy L. Steele,et al.  The Java Language Specification , 1996 .

[11]  Vivek Sarkar,et al.  X10: an object-oriented approach to non-uniform cluster computing , 2005, OOPSLA '05.

[12]  Milo M. K. Martin,et al.  Multifacet's general execution-driven multiprocessor simulator (GEMS) toolset , 2005, CARN.

[13]  Abraham Silberschatz,et al.  Operating System Concepts 8th Edition Binder Ready Version , 2008 .

[14]  Craig Zilles,et al.  Extending Hardware Transactional Memory to Support Non-busy Waiting and Non-transactional Actions , 2006 .

[15]  Ulrich Drepper,et al.  Futexes Are Tricky , 2004 .

[16]  Dan Grossman,et al.  AtomCaml: first-class atomicity via rollback , 2005, ICFP '05.

[17]  Per Brinch Hansen,et al.  Monitors and concurrent Pascal: a personal history , 1993, HOPL-II.

[18]  Bradford Nichols,et al.  Pthreads programming , 1996 .

[19]  A. McDonald,et al.  Architectural Semantics for Practical Transactional Memory , 2006, ISCA 2006.

[20]  Charles Antony Richard Hoare Towards a theory of parallel programming , 2002 .

[21]  Simon L. Peyton Jones,et al.  Composable memory transactions , 2005, CACM.

[22]  Butler W. Lampson,et al.  Experience with processes and monitors in Mesa (Summary) , 1979, SOSP '79.

[23]  David A. Wood,et al.  Performance Pathologies in Hardware Transactional Memory , 2007, IEEE Micro.

[24]  Yannis Smaragdakis,et al.  Transactions with isolation and cooperation , 2007, OOPSLA.