ABSTRACT
We introduce lock allocation, an automatic technique that takes a multi-threaded program annotated with atomic sections (that must be executed atomically), and infers a lock assignment from global variables to locks and a lock instrumentation that determines where each lock should be acquired and released such that the resulting instrumented program is guaranteed to preserve atomicity and deadlock freedom (provided all shared state is accessed only within atomic sections). Our algorithm works in the presence of pointers and procedures, and sets up the lock allocation problem as a 0-1 ILP which minimizes the conflict cost between atomic sections while simultaneously minimizing the number of locks. We have implemented our algorithm for both C with pthreads and Java, and have applied it to infer locks in 15K lines of AOLserver code. Our automatic allocation produces the same results as hand annotations for most of this code, while solving the optimization instances within a second for most programs.
- L.O. Andersen. Program analysis and specialization for the C programming language. PhD thesis, 1994.Google Scholar
- Aolserver. http://www.aolserver.com.Google Scholar
- E.M.L. Beale and J.A. Tomlin. Special facilities in a general mathematical programming system for non-convex problems using ordered sets of variables. In Proc. Intl. Conf. Oper. Res., pages 447--454, 1970. Tavistock.Google Scholar
- N. Een and N. Sorensson. Translating pseudo-boolean constraints into SAT. JSAT, pages 1--26, 2006.Google Scholar
- C. Flanagan and S.N. Freund. Type-based race detection for Java. In PLDI 00, pages 219--232. ACM, 2000. Google ScholarDigital Library
- C. Flanagan, S.N. Freund, and M. Lifshin. Type inference for atomicity. In TLDI 05, pages 47--58. ACM, 2005. Google ScholarDigital Library
- C. Flanagan and S. Qadeer. A type and effect system for atomicity. In PLDI 03, pages 338--349. ACM, 2003. Google ScholarDigital Library
- J. Gray and A. Reuter. Transaction processing: Concepts and Techniques. Morgan-Kaufmann, 1993. Google ScholarDigital Library
- T. Harris and K. Fraser. Language support for lightweight transactions. In OOPSLA 03, pages 388--402, 2003. Google ScholarDigital Library
- M. Hicks, J.S. Foster, and P. Pratikakis. Lock inference for atomic sections. In TRANSACT '06, 2006.Google Scholar
- G. Holzmann. The Spin model checker. IEEE TSE, 23(5):279--295, 1997. Google ScholarDigital Library
- S. Jagannathan and J. Vitek. Optimistic concurrency semantics for transactions in coordination languages. In Intl. Conf. on Coordination Models and Languages, LNCS 2949, pages 183--198. Springer, 2004.Google ScholarCross Ref
- D. B. Lomet. Process structuring, synchronization, and recovery using atomic actions. In Language Design for Reliable Software, pages 128--137, 1977. Google ScholarDigital Library
- B. McCloskey, F. Zhou, D. Gay, and E. Brewer. Autolocker: Synchronization inference for atomic sections. In POPL 06, pages 346--358. ACM, 2006. Google ScholarDigital Library
- G. Naumovich, G.S. Avrunin, and L.A. Clarke. An efficient algorithm for computing MHP information for concurrent Java programs. In FSE 99, pages 338--354. ACM, 1999. Google ScholarDigital Library
- G. Necula, S. McPeak, S. Rahul, and W. Weimer. CIL: Intermediate Language and Tools for Analysis and Transformation of C Programs. In CC '02, pages 213--228, 2002. Google ScholarDigital Library
- N. Nystrom, M. Clarkson, and A. Myers. Polyglot: An Extensible Compiler Framework for Java. In CC '03, pages 138--152, 2003. Google ScholarDigital Library
- M.F. Ringenburg and D. Grossman. Atomcaml: first-class atomicity via rollback. In ICFP 05, pages 92--104. ACM, 2005. Google ScholarDigital Library
- S. Savage, M. Burrows, C.G. Nelson, P. Sobalvarro, and T.A. Anderson. Eraser: A dynamic data race detector for multithreaded programs. ACM TOCS, 15(4):391--411, 1997. Google ScholarDigital Library
- N. Sterling. Warlock: a static data race analysis tool. In USENIX Technical Conference, pages 97--106, 1993.Google Scholar
Index Terms
- Lock allocation
Recommendations
Lock allocation
Proceedings of the 2007 POPL ConferenceWe introduce lock allocation, an automatic technique that takes a multi-threaded program annotated with atomic sections (that must be executed atomically), and infers a lock assignment from global variables to locks and a lock instrumentation that ...
Reducing biased lock revocation by learning
ICOOOLPS '11: Proceedings of the 6th Workshop on Implementation, Compilation, Optimization of Object-Oriented Languages, Programs and SystemsFor languages supporting concurrency the implementation of synchronization primitives is important for achieving high-performance. Many concurrent languages use object based locks to control access to critical regions. When lock ownership doesn't change ...
Transactional lock-free execution of lock-based programs
Special Issue: Proceedings of the 10th annual conference on Architectural Support for Programming Languages and Operating SystemsThis paper is motivated by the difficulty in writing correct high-performance programs. Writing shared-memory multi-threaded programs imposes a complex trade-off between programming ease and performance, largely due to subtleties in coordinating access ...
Comments