Abstract
There are many mechanisms for concurrency control in high-level programming languages. In Java, the original mechanism for concurrency control, based on synchronized blocks, is lexically scoped. For more flexible control, Java 5 introduced non-lexical operators, supporting lock primitives on re-entrant locks. These operators may lead to run-time errors and unwanted behavior; e.g., taking a lock without releasing it, which could lead to a deadlock, or trying to release a lock without owning it. This paper develops a static type and effect system to prevent the mentioned lock errors for non-lexical locks. The effect type system is formalized for an object-oriented calculus which supports non-lexical lock handling. Based on an operational semantics, we prove soundness of the effect type analysis. Challenges in the design of the effect type system are dynamic creation of threads, objects, and especially of locks, aliasing of lock references, passing of lock references between threads, and reentrant locks as found in Java.
The author list is written in alphabetical order. The work is partly funded by the EU project FP7-231620 HATS: Highly Adaptable and Trustworthy Software using FormalModels ( http://www.hats-project.eu ).
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
Amtoft, T., Nielson, H.R., Nielson, F.: Type and Effect Systems: Behaviours for Concurrency. Imperial College Press (1999)
Bigliardi, G., Laneve, C.: A type system for JVM threads. In: Proceedings of 3rd ACM SIGPLAN Workshop on Types in Compilation, TIC 2000, p. 2003 (2000)
DeLine, R., Fähndrich, M.: Enforcing high-level protocols in low-level software. In: Proceedings of the 2001 ACM Conference on Programming Language Design and Implementation, pp. 59–69 (June 2001)
Foster, J.S., Terauchi, T., Aiken, A.: Flow-sensitive type qualifiers. In: Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation (2002)
Gerakios, P., Papaspyrou, N., Sagonas, K.: A concurrent language with a uniform treatment of regions and locks. In: Programming Language Approaches to Concurrency and Communication-eCentric Software. EPTCS, vol. 17, pp. 79–93 (2010)
Igarashi, A., Kobayashi, N.: Resource usage analysis. ACM Transactions on Programming Languages and Systems 27(2), 264–313 (2005)
Igarashi, A., Pierce, B.C., Wadler, P.: Featherweight Java: A minimal core calculus for Java and GJ. In: Object Oriented Programming: Systems, Languages, and Applications, OOPSLA 1999, pp. 132–146. ACM (1999); SIGPLAN Notices
Iwama, F., Kobayashi, N.: A new type system for JVM lock primitives. In: ASIA-PEPM 2002: Proceedings of the ASIAN Symposium on Partial Evaluation and Semantics-Based Program Manipulation, pp. 71–82. ACM, New York (2002)
Jagannathan, S., Vitek, J., Welc, A., Hosking, A.: A transactional object calculus. Science of Computer Programming 57(2), 164–186 (2005)
Johnsen, E.B., Tran, T.M.T, Owe, O., Steffen, M.: Safe locking for multi-threaded Java. Technical Report (revised version) 402, University of Oslo, Dept. of Computer Science (January 2011), www.ifi.uio.no/~msteffen/publications.html#techreports ; A shorter version (extended abstract) has been presented at the NWPT 2010
Tran, T.M.T., Owe, O., Steffen, M.: Safe typing for transactional vs. lock-based concurrency in multi-threaded Java. In: Pham, S.B., Hoang, T.-H., McKay, B., Hirota, K. (eds.) Proceedings of the Second International Conference on Knowledge and Systems Engineering, KSE 2010, pp. 188-193. IEEE Computer Society (October 2010)
Tran, T.M.T., Steffen, M.: Safe Commits for Transactional Featherweight Java. In: Méry, D., Merz, S. (eds.) IFM 2010. LNCS, vol. 6396, pp. 290–304. Springer, Heidelberg (2010); An earlier and longer version has appeared as UiO, Dept. of Comp. Science Technical Report 392, October 2009 and appeared as extended abstract in the Proceedings of NWPT 2009
Oaks, S., Wong, H.: Java Threads, 3rd edn. O’Reilly (September 2004)
Stata, R., Abadi, M.: A type system for Java bytecode subroutines. ACM Transactions on Programming Languages and Systems 21(1), 90–137 (1999)
Suenaga, K.: Type-Based Deadlock-Freedom Verification for Non-Block-Structured Lock Primitives and Mutable References. In: Ramalingam, G. (ed.) APLAS 2008. LNCS, vol. 5356, pp. 155–170. Springer, Heidelberg (2008)
Terauchi, T.: Checking race freedom via linear programming. In: Proceedings of the 2008 ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI 2008, pp. 1–10. ACM, New York (2008)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2012 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Johnsen, E.B., Mai Thuong Tran, T., Owe, O., Steffen, M. (2012). Safe Locking for Multi-threaded Java. In: Arbab, F., Sirjani, M. (eds) Fundamentals of Software Engineering. FSEN 2011. Lecture Notes in Computer Science, vol 7141. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-29320-7_11
Download citation
DOI: https://doi.org/10.1007/978-3-642-29320-7_11
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-642-29319-1
Online ISBN: 978-3-642-29320-7
eBook Packages: Computer ScienceComputer Science (R0)