Types for Safe Locking

A race condition is a situation where two threads manipulate a data structure simultaneously, without synchronization. Race conditions are common errors in multithreaded programming. They often lead to unintended nondeterminism and wrong results. Moreover, they are notoriously hard to diagnose, and attempts to eliminate them can introduce deadlocks. In practice, race conditions and deadlocks are often avoided through prudent programming discipline: protecting each shared data structure with a lock and imposing a partial order on lock acquisitions. In this paper we show that this discipline can be captured (if not completely, to a significant extent) through a set of static rules. We present these rules as a type system for a concurrent, imperative language. Although weaker than a full-blown program-verification calculus, the type system is effective and easy to apply. We emphasize a core, first-order type system focused on race conditions; we also consider extensions with polymorphism, existential types, and a partial order on lock types.

[1]  John H. Reppy,et al.  CML: A higher concurrent language , 1991, PLDI '91.

[2]  Mads Tofte,et al.  Implementation of the typed call-by-value λ-calculus using a stack of regions , 1994, POPL '94.

[3]  David Gay,et al.  Barrier inference , 1998, POPL '98.

[4]  Charles E. Leiserson,et al.  Detecting data races in Cilk programs that use locks , 1998, SPAA '98.

[5]  Flemming Nielson,et al.  Higher-order concurrent programs with finite communication topology (extended abstract) , 1994, POPL '94.

[6]  James C. Corbett,et al.  Evaluating Deadlock Detection Methods for Concurrent Software , 1996, IEEE Trans. Software Eng..

[7]  Lori A. Clarke,et al.  Experimental Design for Comparing Static Concurrency Analysis , 1996 .

[8]  Pierre Jouvelot,et al.  Polymorphic type, region and effect inference , 1992, Journal of Functional Programming.

[9]  Lori A. Clarke,et al.  An empirical comparison of static concurrency analysis techniques , 1996 .

[10]  Christopher Colby Analyzing the communication topology of concurrent programs , 1995, PEPM '95.

[11]  Andrew D. Birrell,et al.  An Introduction to Programming with Threads , 1996 .

[12]  John H. Reppy,et al.  CML: A Higher-Order Concurrent Language , 1991, PLDI.

[13]  Pierre Jouvelot,et al.  Algebraic reconstruction of types and effects , 1991, POPL '91.

[14]  Mads Tofte,et al.  Region-based Memory Management , 1997, Inf. Comput..

[15]  Guy L. Steele,et al.  The Java Language Specification , 1996 .

[16]  Michael Burrows,et al.  Eraser: a dynamic data race detector for multithreaded programs , 1997, TOCS.

[17]  Lori A. Clarke,et al.  Data flow analysis for verifying properties of concurrent programs , 1994, SIGSOFT '94.

[18]  Rajagopal Nagarajan,et al.  A Type-Theoretic Approach to Deadlock-Freedom of Asynchronous Systems , 1997, TACS.

[19]  Lisbeth Fajstrup,et al.  Detecting Deadlocks in Concurrent Systems , 1996 .

[20]  Naoki Kobayashi A partially deadlock-free typed process calculus , 1998, TOPL.

[21]  Michael Burrows,et al.  Eraser: a dynamic data race detector for multi-threaded programs , 1997, TOCS.

[22]  Flemming Nielson,et al.  Type and Behaviour Reconstruction for Higher-Order Concurrent Programs , 1997, J. Funct. Program..

[23]  Flemming Nielson Annotated type and effect systems , 1996, CSUR.

[24]  George S. Avrunin,et al.  Automated Analysis of Concurrent Systems With the Constrained Expression Toolset , 1991, IEEE Trans. Software Eng..

[25]  Nicholas Sterling,et al.  WARLOCK - A Static Data Race Analysis Tool , 1993, USENIX Winter.

[26]  Patrice Godefroid,et al.  Model checking for programming languages using VeriSoft , 1997, POPL '97.

[27]  David K. Gifford,et al.  Polymorphic effect systems , 1988, POPL '88.