Open Systems Laboratory at Illinois

Thread contracts for safe parallelism

By Rajesh K. Karmani, P. Madhusudan, and Brandon M. Moore. In PPOPP, 125–134. ACM, 2011.

Full Text:
Download PDF
Publisher Link:


We build a framework of thread contracts, called Accord, that allows programmers to annotate their concurrency co-ordination strategies. Accord annotations allow programmers to declaratively specify the parts of memory that a thread may read or write into, and the locks that protect them, reflecting the concurrency co-ordination among threads and the reason why the program is free of data-races. We provide automatic tools to check if the concurrency co-ordination strategy ensures race-freedom, using constraint-solvers (SMT solvers). Hence programmers using Accord can both formally state and prove their co-ordination strategies ensure race freedom. The programmer's implementation of the co-ordination strategy may however be correct or incorrect. We show how the formal Accord contracts allow us to automatically insert runtime assertions that serve to check, during testing, whether the implementation conforms to the contract. Using a large class of data-parallel programs that share memory in intricate ways, we show that natural and simple contracts suffice to document the co-ordination strategy amongst threads, and that the task of showing that the strategy ensures race-freedom can be handled efficiently and automatically by an existing SMT solver (Z3). While co-ordination strategies can be proved race-free in our framework, failure to prove the co-ordination strategy race-free, accompanied by counter-examples produced by the solver, indicates the presence of races. Using such counterexamples, we report hitherto undiscovered data-races that we found in the long-tested applu_l benchmark in the Spec OMP2001 suite.


    author = "Karmani, Rajesh K. and Madhusudan, P. and Moore,
              Brandon M.",
    editor = "Cascaval, Calin and Yew, Pen-Chung",
    title = "Thread contracts for safe parallelism",
    booktitle = "PPOPP",
    crossref = "conf/ppopp/2011",
    ee = "",
    keywords = "formal methods, software engineering",
    pages = "125-134",
    year = "2011",

    editor = "Cascaval, Calin and Yew, Pen-Chung",
    title = "Proceedings of the 16th ACM SIGPLAN Symposium on
             Principles and Practice of Parallel Programming, PPOPP 2011, San
             Antonio, TX, USA, February 12-16, 2011",
    ee = "",
    isbn = "978-1-4503-0119-0",
    publisher = "ACM",
    year = "2011",