Abstract
Modern concurrent programming languages like Java and C# have a programming language level memory model; it captures the set of all allowed behaviors of programs on any implementation platform — uni- or multi-processor. Such a memory model is typically weaker than Sequential Consistency and allows reordering of operations within a program thread. Therefore, programs verified correct by assuming Sequential Consistency (that is, each thread proceeds in program order) may not behave correctly on certain platforms! The solution to this problem is to develop program checkers which are memory model sensitive. In this paper, we develop such an invariant checker for the programming language C#. Our checker identifies program states which are reached only because the C# memory model is more relaxed than Sequential Consistency. Furthermore, our checker identifies (a) operation reorderings which cause such undesirable states to be reached, and (b) simple program modifications — by inserting memory barrier operations — which prevent such undesirable reorderings.
This is a preview of subscription content, log in via an institution.
Buying options
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsPreview
Unable to display preview. Download preview PDF.
References
Java Specification Request (JSR) 133. Java Memory Model and Thread Specification revision (2004)
Abrams, B.: http://blogs.msdn.com/brada/archive/2004/05/12/130935.aspx
Brumme, C.: Weblog: Memory model, http://blogs.msdn.com/cbrumme/archive/2003/05/17/51445.aspx
Collier, W.W.: Reasoning about Parallel Architectures. Prentice Hall, Englewood Cliffs (1992)
Dwyer, M.B., et al.: Using static and dynamic escape analysis to enable model reductions in model-checking concurrent object-oriented programs. Technical report, Kansas State Univ. (2003)
Bacon, D., et al.: The ”Double-checked Locking is Broken” declaration, http://www.cs.umd.edu/pugh/java/memoryModel/DoubleCheckedLocking.html
Ford, L.R., Fulkerson, D.R.: Maximum flow through a network. Canad. J. Math 8, 399–404 (1956)
JGF. The Java Grande Forum Multi-threaded Benchmarks (2001), http://www.epcc.ed.ac.uk/computing/research_activities/java_grande/threads.html
JPF. The Java Path Finder model checking tool (2005), http://javapathfinder.sourceforge.net/
Lamport, L.: How to make a multiprocessor computer that correctly executes multiprocess programs. IEEE Transactions on Computers 28(9) (1979)
Lea, D.: The JSR-133 cookbook for compiler writers, http://gee.cs.oswego.edu/dl/jmm/cookbook.html
Manson, J., Pugh, W.: The Java Memory Model Simulator. In: Workshop on Formal Techniques for Java-like Programs, in association with ECOOP (2002)
Manson, J., Pugh, W., Adve, S.: The Java Memory Model. In: ACM Symposium on Principles of Programming Languages (POPL) (2005)
Microsoft. Standard ECMA-335 C# Specification (2005), http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-334.pdf
Microsoft. Standard ECMA-335 Common Language Infrastructure (CLI) (2005), http://www.ecma-international.org/publications/standards/Ecma-335.htm
Morrison, V.: Dotnet discussion: The DOTNET Memory Model, http://discuss.develop.com/archives/wa.exe?A2=ind0203B&L=DOTNET&P=R375
Nalumusu, R., et al.: The “test model checking” approach to the verification of memory models of multiprocessors. In: Computer Aided Verification (CAV) (1998)
Nipkow, T., et al.: Special issue on Java bytecode verification. Journal of Automated Reasoning (JAR) 30(3–4) (2003)
Pugh, W.: Test for sequential consistency of volatiles, http://www.cs.umd.edu/pugh/java/memoryModel/ReadAfterWrite.java
Raynal, M.: Algorithms for mutual exclusion. MIT Press, Cambridge (1986)
Roychoudhury, A., Mitra, T.: Specifying multithreaded Java semantics for program verification. In: ACM Intl. Conf. on Software Engineering (ICSE) (2002)
Schmidt, D., Harrison, T.: Double-checked locking: An optimization pattern for efficiently initializing and accessing thread-safe objects. In: 3rd annual Pattern Languages of Program Design conference (1996)
Stark, R.F., Borger, E.: An ASM specification of C# threads and the.NET memory model. In: ASM Workshop. LNCS, vol. 3065 (2004)
Yang, Y., Gopalakrishnan, G., Lindstrom, G.: Memory model sensitive data race analysis. In: Davies, J., Schulte, W., Barnett, M. (eds.) ICFEM 2004. LNCS, vol. 3308, pp. 30–45. Springer, Heidelberg (2004)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2006 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Huynh, T.Q., Roychoudhury, A. (2006). A Memory Model Sensitive Checker for C#. In: Misra, J., Nipkow, T., Sekerinski, E. (eds) FM 2006: Formal Methods. FM 2006. Lecture Notes in Computer Science, vol 4085. Springer, Berlin, Heidelberg. https://doi.org/10.1007/11813040_32
Download citation
DOI: https://doi.org/10.1007/11813040_32
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-37215-8
Online ISBN: 978-3-540-37216-5
eBook Packages: Computer ScienceComputer Science (R0)