Abstract
Atomicity is a fundamental correctness property in multithreaded programs. A method is atomic if, for every execution, there is an equivalent serial execution in which the actions of the method are not interleaved with actions of other threads. Atomic methods are amenable to sequential reasoning, which significantly facilitates subsequent analysis and verification.
This article presents a type system for specifying and verifying the atomicity of methods in multithreaded Java programs using a synthesis of Lipton's theory of reduction and type systems for race detection. The type system supports guarded, write-guarded, and unguarded fields, as well as thread-local data, parameterized classes and methods, and protected locks. We also present an algorithm for verifying atomicity via type inference.
We have applied our type checker and type inference tools to a number of commonly used Java library classes and programs. These tools were able to verify the vast majority of methods in these benchmarks as atomic, indicating that atomicity is a widespread methodology for multithreaded programming. In addition, reported atomicity violations revealed some subtle errors in the synchronization disciplines of these programs.
Supplemental Material
Available for Download
Online appendix to designing mediation for context-aware applications. The appendix supports the information on article 20.
- Abadi, M., Flanagan, C., and Freund, S. N. 2006. Types for safe locking: Static race detection for Java. ACM Trans. Program. Lang. Syst. 28, 2, 207--255.]] Google Scholar
Digital Library
- Agarwal, R. and Stoller, S. D. 2004. Type inference for parameterized race-free Java. In Proceedings of the Conference on Verification, Model Checking, and Abstract Interpretation. 149--160.]]Google Scholar
- Aiken, A. and Gay, D. 1998. Barrier inference. In Proceedings of the ACM Symposium on the Principles of Programming Languages. 243--354.]] Google Scholar
Digital Library
- Artho, C., Havelund, K., and Biere, A. 2003. High-level data races. In Proceedings of the First International Workshop on Verification and Validation of Enterprise Information Systems.]]Google Scholar
- Back, R.-J. 1989. A method for refining atomicity in parallel algorithms. In Proceedings of the Parallel Architectures and Languages Europe (PARLE'89). Lecture Notes in Computer Science, vol. 366. Springer-Verlag, 199--216.]] Google Scholar
Digital Library
- Birrell, A. D. 1989. An introduction to programming with threads. Res. rep. 35, Digital Equipment Corporation Systems Research Center.]]Google Scholar
- Boyapati, C., Lee, R., and Rinard, M. 2002. A type system for preventing data races and deadlocks in Java programs. In Proceedings of the ACM Conference on Object-Oriented Programming, Systems, Languages and Applications. 211--230.]] Google Scholar
Digital Library
- Boyapati, C. and Rinard, M. 2001. A parameterized type system for race-free Java programs. In Proceedings of the ACM Conference on Object-Oriented Programming, Systems, Languages and Applications. 56--69.]] Google Scholar
Digital Library
- Bruening, D. 1999. Systematic testing of multithreaded Java programs. M.S. thesis, Massachusetts Institute of Technology.]]Google Scholar
- Bryant, R. 1986. Graph-based algorithms for boolean function manipulation. IEEE Trans. Comput. C-35, 8, 677--691.]] Google Scholar
Digital Library
- Burrows, M. and Leino, K. R. M. 2002. Finding stale-value errors in concurrent programs. Technical Note 2002-004, Compaq Systems Research Center.]]Google Scholar
- Cardelli, L. 1988. Typechecking dependent types and subtypes. Lecture Notes in Computer Science, Foundations of Logic and Functional Programming. 45--57.]] Google Scholar
Digital Library
- Chamillard, A. T., Clarke, L. A., and Avrunin, G. S. 1996. An empirical comparison of static concurrency analysis techniques. Tech. rep. 96-084, Department of Computer Science, University of Massachusetts at Amherst.]] Google Scholar
Digital Library
- Choi, J.-D., Gupta, M., Serrano, M. J., Sreedhar, V. C., and Midkiff, S. P. 1999. Escape analysis for Java. In Proceedings of the ACM Conference on Object-Oriented Programming, Systems, Languages and Applications. 1--19.]] Google Scholar
Digital Library
- Choi, J.-D., Lee, K., Loginov, A., O'Callahan, R., Sarkar, V., and Sridhara, M. 2002. Efficient and precise datarace detection for multithreaded object-oriented programs. In Proceedings of the ACM Conference on Programming Language Design and Implementation. 258--269.]] Google Scholar
Digital Library
- Cohen, E. and Lamport, L. 1998. Reduction in TLA. In Proceedings of the International Conference on Concurrency Theory. Lecture Notes in Computer Science, vol. 1466. Springer-Verlag, 317--331.]] Google Scholar
Digital Library
- Corbett, J. C. 1996. Evaluating deadlock detection methods for concurrent software. IEEE Trans. Softw. Eng. 22, 3, 161--180.]] Google Scholar
Digital Library
- DeLine, R. and Fähndrich, M. 2001. Enforcing high-level protocols in low-level software. In Proceedings of the ACM Conference on Programming Language Design and Implementation. 59--69.]] Google Scholar
Digital Library
- Deng, X., Dwyer, M., Hatcliff, J., and Mizuno, M. 2002. Invariant-based specification, synthesis, and verification of synchronization in concurrent programs. In Proceedings of the International Conference on Software Engineering. 442--452.]] Google Scholar
Digital Library
- Detlefs, D. L., Leino, K. R. M., and Nelson, C. G. 1998. Wrestling with rep exposure. Research rep. 156, DEC Systems Research Center.]]Google Scholar
- Doeppner, Jr., T. W. 1977. Parallel program correctness through refinement. In Proceedings of the ACM Symposium on the Principles of Programming Languages. 155--169.]] Google Scholar
Digital Library
- Eppinger, J. L., Mummert, L. B., and Spector, A. Z. 1991. Camelot and Avalon: A Distributed Transaction Facility. Morgan Kaufmann.]] Google Scholar
Digital Library
- Flanagan, C. 2004. Verifying commit-atomicity using model-checking. In Proceedings of the International SPIN Workshop on Model Checking of Software.]]Google Scholar
Cross Ref
- Flanagan, C. and Abadi, M. 1999a. Object types against races. In Proceedings of the International Conference on Concurrency Theory. Lecture Notes in Computer Science, vol. 1664. 288--303.]] Google Scholar
Digital Library
- Flanagan, C. and Abadi, M. 1999b. Types for safe locking. In Proceedings of European Symposium on Programming. Lecture Notes in Computer Science, vol. 1576. 91--108.]] Google Scholar
Digital Library
- Flanagan, C. and Freund, S. N. 2000. Type-based race detection for Java. In Proceedings of the ACM Conference on Programming Language Design and Implementation. 219--232.]] Google Scholar
Digital Library
- Flanagan, C. and Freund, S. N. 2004a. Atomizer: A dynamic atomicity checker for multithreaded programs. In Proceedings of the ACM Symposium on the Principles of Programming Languages. 256--267.]] Google Scholar
Digital Library
- Flanagan, C. and Freund, S. N. 2004b. Type inference against races. In Proceedings of the Static Analysis Symposium. 116--132.]]Google Scholar
- Flanagan, C. and Freund, S. N. 2005. Automatic synchronization correction. In Proceedings of the Workshop on Synchronization and Concurrency in Object-Oriented Languages.]]Google Scholar
- Flanagan, C., Freund, S. N., and Lifshin, M. 2005. Type inference for atomicity. In Proceedings of the ACM Workshop on Types in Language Design and Implementation. 47--58.]] Google Scholar
Digital Library
- Flanagan, C., Freund, S. N., and Qadeer, S. 2005. Exploiting purity for atomicity. IEEE Trans. Softw. Eng. 31, 4, 275--291.]] Google Scholar
Digital Library
- Flanagan, C., Leino, K. R. M., Lillibridge, M., Nelson, G., Saxe, J. B., and Stata, R. 2002. Extended static checking for Java. In Proceedings of the ACM Conference on Programming Language Design and Implementation. 234--245.]] Google Scholar
Digital Library
- Flanagan, C. and Qadeer, S. 2003a. Transactions for software model checking. In Proceedings of the Workshop on Software Model Checking.]]Google Scholar
- Flanagan, C. and Qadeer, S. 2003b. A type and effect system for atomicity. In Proceedings of the ACM Conference on Programming Language Design and Implementation. 338--349.]] Google Scholar
Digital Library
- Flanagan, C. and Qadeer, S. 2003c. Types for atomicity. In Proceedings of the ACM Workshop on Types in Language Design and Implementation. 1--12.]] Google Scholar
Digital Library
- Flatt, M., Krishnamurthi, S., and Felleisen, M. 1998. Classes and mixins. In Proceedings of the ACM Symposium on the Principles of Programming Languages. 171--183.]] Google Scholar
Digital Library
- Freund, S. N. and Qadeer, S. 2004. Checking concise specifications for multithreaded software. J. Object Tech. 3, 6, 81--101.]]Google Scholar
Cross Ref
- Gharachorloo, K. 1995. Memory consistency models for shared-memory multiprocessors. Ph.D. thesis, Stanford University.]] Google Scholar
Digital Library
- Goetz, B., Peierls, T., Bloch, J., Bowbeer, J., Holmes, D., and Lea, D. 2006. Java Concurrency in Practice. Addison-Wesley.]] Google Scholar
Digital Library
- Gosling, J., Joy, B., and Steele, G. 1996. The Java Language Specification. Addison-Wesley.]] Google Scholar
Digital Library
- Grossman, D. 2003. Type-safe multithreading in Cyclone. In Proceedings of the ACM Workshop on Types in Language Design and Implementation. 13--25.]] Google Scholar
Digital Library
- Haack, C. and Wells, J. B. 2003. Type error slicing in implicitly typed higher-order languages. In Proceedings of the European Symposium on Programming. 284--301.]] Google Scholar
Digital Library
- Harris, T. and Fraser, K. 2003. Language support for lightweight transactions. In Proceedings of the ACM Conference on Object-Oriented Programming, Systems, Languages and Applications. 388--402.]] Google Scholar
Digital Library
- Hatcliff, J., Robby, and Dwyer, M. B. 2004. Verifying atomicity specifications for concurrent object-oriented software using model-checking. In Proceedings of the International Conference on Verification, Model Checking and Abstract Interpretation. 175--190.]]Google Scholar
- Herlihy, M. P. and Wing, J. M. 1990. Linearizability: A correctness condition for concurrent objects. ACM Trans. Program. Lang. Syst. 12, 3, 463--492.]] Google Scholar
Digital Library
- Hicks, M., Foster, J. S., and Pratikakis, P. 2006. Inferring locking for atomic sections. In Proceedings of the Workshop on Languages, Compilers, and Hardware Support for Transactional Computing.]]Google Scholar
- Hoare, C. 1974. Monitors: an operating systems structuring concept. Comm. ACM 17, 10, 549--557.]] Google Scholar
Digital Library
- Hoare, C. A. R. 1972. Towards a theory of parallel programming. In Operating Systems Techniques. A.P.I.C. Studies in Data Processing, vol. 9. 61--71.]]Google Scholar
- Java Grande Forum. 2003. Java Grande benchmark suite. http://www.javagrande.org/.]]Google Scholar
- JavaSoft. 2005. Java Developers Kit, version 1.4.0. http://java.sun.com.]]Google Scholar
- Lamport, L. 1978. Time, clocks, and the ordering of events in a distributed system. Comm. ACM 21, 7, 558--565.]] Google Scholar
Digital Library
- Lamport, L. and Schneider, F. B. 1989. Pretending atomicity. Research rep. 44, DEC Systems Research Center.]]Google Scholar
- Lea, D. 2004. The util.concurrent package, release 1.3.4. http://gee.cs.oswego.edu/dl/.]]Google Scholar
- Lipton, R. J. 1975. Reduction: A method of proving properties of parallel programs. Comm. ACM 18, 12, 717--721.]] Google Scholar
Digital Library
- Liskov, B., Curtis, D., Johnson, P., and Scheifler, R. 1987. Implementation of Argus. In Proceedings of the Symposium on Operating Systems Principles. 111--122.]] Google Scholar
Digital Library
- Lomet, D. B. 1977. Process structuring, synchronization, and recovery using atomic actions. Lang. Design Reliable Softw., 128--137.]] Google Scholar
Digital Library
- Lucassen, J. M. and Gifford, D. K. 1988. Polymorphic effect systems. In Proceedings of the ACM Conference on Lisp and Functional Programming. 47--57.]] Google Scholar
Digital Library
- Manson, J., Pugh, W., and Adve, S. V. 2005. The Java memory model. In Proceedings of the ACM Symposium on the Principles of Programming Languages. 378--391.]] Google Scholar
Digital Library
- McCloskey, B., Zhou, F., Gay, D., and Brewer, E. 2006. Autolocker: synchronization inference for atomic sections. In Proceedings of the ACM Symposium on the Principles of Programming Languages. 346--358.]] Google Scholar
Digital Library
- Misra, J. 2001. A Discipline of Multiprogramming: Programming Theory for Distributed Applications. Springer-Verlag.]] Google Scholar
Digital Library
- Naik, M., Aiken, A., and Whaley, J. 2006. Effective static race detection for Java. In Proceedings of the ACM Conference on Programming Language Design and Implementation. 308--319.]] Google Scholar
Digital Library
- O'Callahan, R. and Choi, J.-D. 2003. Hybrid dynamic data race detection. In Proceedings of the ACM Symposium on Principles and Practice of Parallel Programming. 167--178.]] Google Scholar
Digital Library
- Papadimitriou, C. 1986. The Theory of Database Concurrency Control. Computer Science Press.]] Google Scholar
Digital Library
- Pozniansky, E. and Schuster, A. 2003. Efficient on-the-fly data race detection in multihreaded C++ programs. In Proceedings of the ACM Symposium on Principles and Practice of Parallel Programming. 179--190.]] Google Scholar
Digital Library
- Pratikakis, P., Foster, J. S., and Hicks, M. 2006. Context-sensitive correlation analysis for detecting races. In Proceedings of the ACM Conference on Programming Language Design and Implementation. 320--331.]] Google Scholar
Digital Library
- Qadeer, S., Rajamani, S. K., and Rehof, J. 2004. Summarizing procedures in concurrent programs. In Proceedings of the ACM Symposium on the Principles of Programming Languages. 245--255.]] Google Scholar
Digital Library
- Ringenburg, M. F. and Grossman, D. 2005. AtomCaml: first-class atomicity via rollback. In Proceedings of the ACM International Conference on Functional Programming. 92--104.]] Google Scholar
Digital Library
- Salcianu, A. and Rinard, M. 2001. Pointer and escape analysis for multithreaded programs. In Proceedings of the Symposium on Principles and Practice of Parallel Programming. 12--23.]] Google Scholar
Digital Library
- Sasturkar, A., Agarwal, R., Wang, L., and Stoller, S. D. 2005. Automated type-based analysis of data races and atomicity. In Proceedings of the ACM Symposium on Principles and Practice of Parallel Programming. 83--94.]] Google Scholar
Digital Library
- Savage, S., Burrows, M., Nelson, G., Sobalvarro, P., and Anderson, T. E. 1997. Eraser: A dynamic data race detector for multi-threaded programs. ACM Trans. Comput. Syst. 15, 4, 391--411.]] Google Scholar
Digital Library
- SPEC. 2000. Standard Performance Evaluation Corporation JBB2000 Benchmark. Available from http://www.spec.org/osg/jbb2000/.]]Google Scholar
- Sterling, N. 1993. Warlock: A static data race analysis tool. In Proceedings of the USENIX Winter Technical Conference. 97--106.]]Google Scholar
- Stoller, S. 2006. Personal communication.]]Google Scholar
- Stoller, S. D. 2000. Model-checking multi-threaded distributed Java programs. In Proceedings of the Workshop on Model Checking and Software Verification. Lecture Notes in Computer Science, vol. 1885. Springer-Verlag, 224--244.]] Google Scholar
Digital Library
- Talpin, J.-P. and Jouvelot, P. 1992. Polymorphic type, region and effect inference. J. Funct. Program. 2, 3, 245--271.]]Google Scholar
Cross Ref
- Tofte, M. and Talpin, J.-P. 1994. Implementation of the typed call-by-value lambda-calculus using a stack of regions. In Proceedings of the ACM Symposium on the Principles of Programming Languages. 188--201.]] Google Scholar
Digital Library
- Vaziri, M., Tip, F., and Dolby, J. 2006. Associating synchronization constraints with data in an object-oriented language. In Proceedings of the ACM Symposium on the Principles of Programming Languages. 334--345.]] Google Scholar
Digital Library
- von Praun, C. and Gross, T. 2001. Object race detection. In Proceedings of the ACM Conference on Object-Oriented Programming, Systems, Languages and Applications. 70--82.]] Google Scholar
Digital Library
- von Praun, C. and Gross, T. 2003. Static conflict analysis for multi-threaded object-oriented programs. In Proceedings of the ACM Conference on Programming Language Design and Implementation. 115--128.]] Google Scholar
Digital Library
- Wand, M. 1986. Finding the source of type errors. In Proceedings of the ACM Symposium on the Principles of Programming Languages. 38--43.]] Google Scholar
Digital Library
- Wang, L. and Stoller, S. D. 2003. Runtime analysis for atomicity. In Proceedings of the Workshop on Runtime Verification.]]Google Scholar
- Wang, L. and Stoller, S. D. 2006. Runtime analysis of atomicity for multithreaded programs. IEEE Trans. Softw. Eng. 32, 2, 93--110.]] Google Scholar
Digital Library
- Welc, A., Jagannathan, S., and Hosking, A. L. 2004. Transactional monitors for concurrent objects. In Proceedings of the European Conference on Object-Oriented Programming. 519--542.]]Google Scholar
- Yang, J., Michaelson, G., Trinder, P., and Wells, J. B. 2000. Improved type error reporting. In Proceedings of the International Workshop on Implementation of Functional Languages. 71--86.]]Google Scholar
Index Terms
Types for atomicity: Static checking and inference for Java
Recommendations
A type and effect system for atomicity
Ensuring the correctness of multithreaded programs is difficult, due to the potential for unexpected and nondeterministic interactions between threads. Previous work addressed this problem by devising tools for detecting race conditions, a situation ...
Automated type-based analysis of data races and atomicity
PPoPP '05: Proceedings of the tenth ACM SIGPLAN symposium on Principles and practice of parallel programmingConcurrent programs are notorious for containing errors that are difficult to reproduce and diagnose at run-time. This motivated the development of type systems that statically ensure the absence of some common kinds of concurrent programming errors ...
A type and effect system for atomicity
PLDI '03: Proceedings of the ACM SIGPLAN 2003 conference on Programming language design and implementationEnsuring the correctness of multithreaded programs is difficult, due to the potential for unexpected and nondeterministic interactions between threads. Previous work addressed this problem by devising tools for detecting race conditions, a situation ...






Comments