ABSTRACT
Seqlocks are an important synchronization mechanism and represent a significant improvement over conventional reader-writer locks in some contexts. They avoid the need to update a synchronization variable during a reader critical section, and hence improve performance by avoiding cache coherence misses on the lock object itself. Unfortunately, they rely on speculative racing loads inside the critical section. This makes them an interesting problem case for programming-language-level memory models that emphasize data-race-free programming. We analyze a variety of implementation alternatives within the C++11 memory model, and briefly address the corresponding issue in Java. In the process, we observe that there may be a use for "read-dont-modify-write" operations, i. e. read-modify-write operations that atomically write back the original value, without modifying it, solely for the memory model consequences, and that it may be useful for compilers to optimize such operations.
- S. V. Adve and H.-J. Boehm. Memory models: A case for rethinking parallel languages and hardware. Communications of the ACM, 53(8):90--101, August 2010. Google ScholarDigital Library
- M. Batty, K. Memarian, S. Owens, S. Sarkar, and P. Sewell. Clarifying and compiling C/C++ concurrency: From C++11 to POWER. In POPL'12, 2012. Google ScholarDigital Library
- M. Batty, S. Owens, S. Sarkar, P. Sewell, and T. Weber. Mathematizing C++ concurrency. In POPL'11, pages 55--66, 2011. Google ScholarDigital Library
- H.-J. Boehm. The atomic_ops atomic operations package. http://www.hpl.hp.com/research/linux/atomic_ops/, 2005.Google Scholar
- H.-J. Boehm. Reordering constraints for pthread-style locks. In Proc. 12th Symp. Principles and Practice of Parallel Programming, pages 173--182, 2007. Google ScholarDigital Library
- H.-J. Boehm. How to miscompile programs with "benign" data races. In HotPar, 2011. Google ScholarDigital Library
- H.-J. Boehm. Performance implications of fence-based memory models. In MSPC, 2011. Google ScholarDigital Library
- H.-J. Boehm and S. Adve. Foundations of the C++ concurrency memory model. In Proc. Conf. on Programming Language Design and Implementation, pages 68--78, 2008. Google ScholarDigital Library
- A. Dragojevic, R. Guerraoui, and M. Kapalka. Stretching transactional memory. In PLDI, 2009. Google ScholarDigital Library
- S. Hemminger. Fast reader/writer lock for gettimeofday 2.5.30. Linux kernel mailing list August 12, 2002, http://lwn.net/Articles/7388/.Google Scholar
- ISO JTC1/SC22/WG21. ISO/IEC 14882:2011, information technology --- programming languages --- C++. http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=50372 or a close approximation at http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3376.pdf.Google Scholar
- C. Lameter. Effective synchronization on Linux/NUMA systems. Proceedings of the May 2005 Gelato Federation Meeting (http://www.lameter.com/gelato2005.pdf), 2005.Google Scholar
- L. Lamport. How to make a multiprocessor computer that correctly executes multiprocess programs. IEEE Transactions on Computers, C-28(9):690--691, 1979. Google ScholarDigital Library
- D. Lea. jsr166e: Class SequenceLock. http://gee.cs.oswego.edu/dl/jsr166/dist/jsr166edocs/jsr166e/SequenceLock.html, retrieved Mar. 8, 2012.Google Scholar
- D. Marino, A. Singh, T. Millstein, M. Musuvathi, and S. Narayanasami. A case for an sc-preserving compiler. In PLDI, 2011. Google ScholarDigital Library
- P. E. McKenney. Exploiting Deferred Destruction: An Analysis of Read-Copy-Update Techniques in Operating System Kernels. PhD thesis, OGI School of Engineering at Oregon Health and Science University, 2004. Google ScholarDigital Library
- T. Nkaike and M. Michael. Lock elision for read-only critical sections in java. In PLDI, 2010. Google ScholarDigital Library
- J. Sevcik. Program Transformations in Weak Memory Models. PhD thesis, University of Edinburgh, 2008.Google Scholar
- J. Sevcik and D. Aspinall. On validity of program transformations in the java memory model. In ECOOP 2008, pages 27--51, 2008. Google ScholarDigital Library
- J. Sevcik and P. Sewell. C/C++11 mappings to processors. http://www.cl.cam.ac.uk/~pes20/cpp/cpp0xmappings.html", retrieved Mar. 3, 2012, 2011.Google Scholar
- P. Sewell, S. Sarkar, S. Owens, F. Z. Nardelli, and M. O. Myreen. x86-tso: A rigorous and usable programmer's model for x86 multiprocesors. Communications of the ACM, 53(7):89--97, July 2010. Google ScholarDigital Library
Index Terms
- Can seqlocks get along with programming language memory models?
Recommendations
Outlawing ghosts: avoiding out-of-thin-air results
MSPC '14: Proceedings of the workshop on Memory Systems Performance and CorrectnessIt is very difficult to define a programming language memory model for shared variables that both
• allows programmers to take full advantage of weakly-ordered memory operations, but still
• correctly disallows so-called "out-of-thin-air" results, i.e. ...
Foundations of the C++ concurrency memory model
PLDI '08Currently multi-threaded C or C++ programs combine a single-threaded programming language with a separate threads library. This is not entirely sound [7].
We describe an effort, currently nearing completion, to address these issues by explicitly ...
Performance implications of fence-based memory models
MSPC '11: Proceedings of the 2011 ACM SIGPLAN Workshop on Memory Systems Performance and CorrectnessMost mainstream shared-memory parallel programming languages are converging to a memory model, or shared variable semantics, centered on providing sequential consistency for most data-race-free programs.
OpenMP, along with a small number of other ...
Comments