skip to main content
10.1145/1929553.1929558acmconferencesArticle/Chapter ViewAbstractPublication PagespoplConference Proceedingsconference-collections
research-article

A type and effect system for deadlock avoidance in low-level languages

Published: 25 January 2011 Publication History

Abstract

The possibility to run into a deadlock is an annoying and commonly occurring hazard associated with the concurrent execution of programs. In this paper we present a polymorphic type and effect system that can be used to dynamically avoid deadlocks, guided by information about the order of lock and unlock operations which is computed statically. In contrast to most other type-based approaches to deadlock freedom, our system does not insist that programs adhere to a strict lock acquisition order or use locking primitives in a block-structured way. Lifting these restrictions is primarily motivated by our desire to target low-level languages, such as C with pthreads, but it also allows our system to be directly applicable in optimizing compilers for high-level languages, such as Java.
To show the effectiveness of our approach, we have also developed a tool that uses static analysis to instrument concurrent programs written in C/pthreads and then links these programs with a run-time system that avoids possible deadlocks. Although our tool is still in an early development stage, in the sense that currently its analysis only handles a limited class of programs, our benchmark results are very promising: they show that it is not only possible to avoid all deadlocks with a small run-time overhead, but also often achieve better throughput in highly concurrent programs by naturally reducing lock contention.

References

[1]
G. Boudol. A deadlock-free semantics for shared memory concurrency. In M. Leucker and C. Morgan, editors, Proceedings of the International Colloquium on Theoretical Aspects of Computing, volume 5684 of LNCS, pages 140--154. Springer, 2009.
[2]
C. Boyapati, R. Lee, and M. Rinard. Ownership types for safe programming: Preventing data races and deadlocks. In Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications, pages 211--230, New York, NY, USA, Nov. 2002. ACM Press.
[3]
E. G. Coffman, M. Elphick, and A. Shoshani. System deadlocks. ACM Comput. Surv., 3(2):67--78, 1971.
[4]
D. Engler and K. Ashcraft. RacerX: effective, static detection of race conditions and deadlocks. In Proceedings of ACM Symposium on Operating Systems Principles, pages 237--252, New York, NY, USA, 2003. ACM.
[5]
flam3.com. Cosmic recursive fractal flames. http://flam3.com/.
[6]
C. Flanagan and M. Abadi. Types for safe locking. In Programming Language and Systems: Proceedings of the European Symposium on Programming, number 1576 in LNCS, pages 91--108. Springer, 1999.
[7]
C. Flanagan, K. R. M. Leino, M. Lillibridge, G. Nelson, J. B. Saxe, and R. Stata. Extended static checking for Java. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation, pages 234--245, New York, NY, USA, 2002. ACM.
[8]
P. Gerakios, N. Papaspyrou, and K. Sagonas. Race-free and memory-safe multithreading: Design and implementation in Cyclone. In Proceedings of the ACM SIGPLAN International Workshop on Types in Languages Design and Implementation, pages 15--26, New York, NY, USA, 2010. ACM Press.
[9]
P. Gerakios, N. Papaspyrou, and K. Sagonas. A type and effect system for deadlock avoidance in low-level languages. Technical report, National Technical University of Athens, 2010.
[10]
P. Gerakios, N. Papaspyrou, and K. Sagonas. A type system for unstructured locking that guarantees deadlock freedom without imposing a lock ordering. In Pre-proceedings of the Workshop on Programming Language Approaches to Concurrency and communication-cEntric Software (PLACES), 2010. An extended version of this paper is available from http://www.softlab.ntua.gr/ pgerakios/deadlocks/.
[11]
D. Grossman, G. Morrisett, T. Jim, M. Hicks, Y. Wang, and J. Cheney. Region-based memory management in Cyclone. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation, pages 282--293, New York, NY, USA, 2002. ACM Press.
[12]
M. Hicks, J. S. Foster, and P. Pratikakis. Lock inference for atomic sections. In Proceedings of the First ACM SIGPLAN Workshop on Languages Compilers, and Hardware Support for Transactional Computing, June 2006.
[13]
H. Jula, D. Tralamazza, C. Zamfir, and G. Candea. Deadlock immunity: Enabling systems to defend against deadlocks. In R. Draves and R. van Renesse, editors, Symposium on Operating Systems Design and Implementation, pages 295--308. USENIX Association, 2008.
[14]
N. Kobayashi. A new type system for deadlock-free processes. In C. Baier and H. Hermanns, editors, CONCUR 2006, volume 4137 of LNCS, pages 233--247. Springer, 2006.
[15]
L. Lamport. A new approach to proving the correctness of multiprocess programs. ACM Trans. Prog. Lang. Syst., 1(1):84--97, 1979.
[16]
G. C. Necula, S. McPeak, S. P. Rahul, and W. Weimer. CIL: Intermediate language and tools for analysis and transformation of C programs. In Compiler Construction: Proceedings of the International Conference, volume 2304 of LNCS, pages 213--228. Springer, 2002.
[17]
F. Qin, J. Tucek, Y. Zhou, and J. Sundaresan. Rx: Treating bugs as allergies -- a safe method to survive software failures. ACM Trans. Comput. Syst., 25(3):7/2, 2007.
[18]
SSH FileSystem. http://fuse.sourceforge.net/sshfs.html.
[19]
K. Suenaga. Type-based deadlock-freedom verification for non-block-structured lock primitives and mutable references. In G. Ramalingam, editor, Asian Symposium on Programming Languages and Systems, volume 5356 of LNCS, pages 155--170. Springer, 2008.
[20]
Multithreaded grep. Part of Sun Microsystems' Multithreaded Programming Guide, available at http://docs.sun.com/app/docs/doc/806-5257.
[21]
Multithreaded HTTP server. http://www.xmailserver.org/thrhttp.c.
[22]
V. Vasconcelos, F. Martin, and T. Cogumbreiro. Type inference for deadlock detection in a multithreaded polymorphic typed assembly language. In A. R. Beresford and S. Gay, editors, Post-proceedings of the Workshop on Programming Language Approaches to Concurrency and communication-cEntric Software (PLACES 2009), volume 17 of EPTCS, pages 95--109, 2010.
[23]
J. W. Voung, R. Jhala, and S. Lerner. RELAY: static race detection on millions of lines of code. In Proceedings of the joint meeting of the European Software Engineering Conference and the ACM SIGSOFT Symposium on the Foundations of Software Engineering, pages 205--214, New York, NY, USA, 2007. ACM.
[24]
Y. Wang, T. Kelly, M. Kudlur, S. Lafortune, and S. Mahlke. Gadara: Dynamic deadlock avoidance for multithreaded programs. In R. Draves and R. van Renesse, editors, Symposium on Operating Systems Design and Implementation, pages 281--294. USENIX Association, 2008.
[25]
Y. Wang, S. Lafortune, T. Kelly, M. Kudlur, and S. Mahlke. The theory of deadlock avoidance via discrete control. In Conference Record of the ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages 252--263, New York, NY, USA, 2009. ACM.

Cited By

View all
  • (2021)Deadlock Avoidance Algorithms for Recursion-Tree Modeled Requests in Parallel ExecutionsIEEE Transactions on Computers10.1109/TC.2021.3122843(1-1)Online publication date: 2021
  • (2021)A Compositional Deadlock Detector for Android Java2021 36th IEEE/ACM International Conference on Automated Software Engineering (ASE)10.1109/ASE51524.2021.9678572(955-966)Online publication date: Nov-2021
  • (2019)Case Study on Design and Evaluation of a Multi-Soft-Core Processor2019 IEEE 10th Annual Information Technology, Electronics and Mobile Communication Conference (IEMCON)10.1109/IEMCON.2019.8936221(0589-0594)Online publication date: Oct-2019
  • Show More Cited By

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Conferences
TLDI '11: Proceedings of the 7th ACM SIGPLAN workshop on Types in language design and implementation
January 2011
94 pages
ISBN:9781450304849
DOI:10.1145/1929553
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

Sponsors

In-Cooperation

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 25 January 2011

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. c
  2. deadlock avoidance
  3. pthreads
  4. types and effects

Qualifiers

  • Research-article

Conference

POPL '11
Sponsor:

Acceptance Rates

Overall Acceptance Rate 11 of 26 submissions, 42%

Upcoming Conference

POPL '26

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)8
  • Downloads (Last 6 weeks)1
Reflects downloads up to 20 Feb 2025

Other Metrics

Citations

Cited By

View all
  • (2021)Deadlock Avoidance Algorithms for Recursion-Tree Modeled Requests in Parallel ExecutionsIEEE Transactions on Computers10.1109/TC.2021.3122843(1-1)Online publication date: 2021
  • (2021)A Compositional Deadlock Detector for Android Java2021 36th IEEE/ACM International Conference on Automated Software Engineering (ASE)10.1109/ASE51524.2021.9678572(955-966)Online publication date: Nov-2021
  • (2019)Case Study on Design and Evaluation of a Multi-Soft-Core Processor2019 IEEE 10th Annual Information Technology, Electronics and Mobile Communication Conference (IEMCON)10.1109/IEMCON.2019.8936221(0589-0594)Online publication date: Oct-2019
  • (2018)A systematic survey on automated concurrency bug detection, exposing, avoidance, and fixing techniquesSoftware Quality Journal10.1007/s11219-017-9385-326:3(855-889)Online publication date: 1-Sep-2018
  • (2017)Adaptively generating high quality fixes for atomicity violationsProceedings of the 2017 11th Joint Meeting on Foundations of Software Engineering10.1145/3106237.3106239(303-314)Online publication date: 21-Aug-2017
  • (2016)SliderInternational Journal of High Performance Systems Architecture10.1504/IJHPSA.2016.0761936:1(36-50)Online publication date: 1-Apr-2016
  • (2016)Locking discipline inference and checkingProceedings of the 38th International Conference on Software Engineering10.1145/2884781.2884882(1133-1144)Online publication date: 14-May-2016
  • (2016)Fixing deadlocks via lock pre-acquisitionsProceedings of the 38th International Conference on Software Engineering10.1145/2884781.2884819(1109-1120)Online publication date: 14-May-2016
  • (2015)Jthread, a deadlock-free mutex libraryProceedings of the 17th International Symposium on Principles and Practice of Declarative Programming10.1145/2790449.2790523(149-160)Online publication date: 14-Jul-2015
  • (2014)Static safety guarantees for a low-level multithreaded language with regionsScience of Computer Programming10.5555/2748144.274839080:PB(223-263)Online publication date: 1-Feb-2014
  • Show More Cited By

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Figures

Tables

Media

Share

Share

Share this Publication link

Share on social media