Types for safe resource sharing in sequential and concurrent programming

  • Authors:
  • Hongwei Xi;Rui Shi

  • Affiliations:
  • Boston University;Boston University

  • Venue:
  • Types for safe resource sharing in sequential and concurrent programming
  • Year:
  • 2008

Quantified Score

Hi-index 0.00

Visualization

Abstract

Though the potential of linear logic in facilitating reasoning on resource usage has long been recognized, its convincing use in practice is still rare. Recently, Zhu and Xi developed a type system that can effectively support safe memory manipulation through pointers. However, this linear type system does not provide adequate support for resource sharing. As a consequence, it requires that resources be threaded through functions, which can cause serious difficulties in practice (e.g. program modularity may be sacrificed) and thus severely restrict the use of linear types. In this dissertation, we develop a general type-theoretical framework for supporting safe sharing of linear resources. In sequential programming, we first introduce a modality, which we refer to as the sharing modality, in support of resource sharing (with no use of locks). We then develop the underlying type theory for the sharing modality and establish its soundness based on a notion of types with effects. Also, an intimate relation between this modality and the issue of code reentrancy is formally studied in this context. Next, we formalize a concurrent programming language equipped with a linear type system and establish its soundness, which guarantees that many common safety violations (e.g., race conditions and resource corruptions) can never occur during the evaluation of a well-typed program. A novel aspect of this language lies in a formal treatment of linear locks for protecting shared resources. The resources protected by linear locks cannot be leaked, as such locks are themselves a form of resources that must be safely reclaimed after their use. We carry out the type theoretical development in the Applied Type System framework, which makes it standard to accommodate (universally and existentially quantified) dependent types, polymorphic types and also a paradigm of programming with theorem proving. We use the programming language ATS for implementation and present a variety of realistic running examples in support of practical use of the developed type theory. As a significant and interesting application, we describe an approach to constructing reliable Linux device drivers in ATS, providing a solid proof of concept.