Safe Locking for Multi-threaded Java
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.
KeywordsOperational Semantic Mutual Exclusion Concurrency Control Method Body Program Language Design
Unable to display preview. Download preview PDF.
- 1.Amtoft, T., Nielson, H.R., Nielson, F.: Type and Effect Systems: Behaviours for Concurrency. Imperial College Press (1999)Google Scholar
- 2.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)Google Scholar
- 3.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)Google Scholar
- 4.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)Google Scholar
- 5.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)Google Scholar
- 7.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 NoticesGoogle Scholar
- 10.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
- 11.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)Google Scholar
- 12.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 CrossRefGoogle Scholar
- 13.Oaks, S., Wong, H.: Java Threads, 3rd edn. O’Reilly (September 2004)Google Scholar