From Non-preemptive to Preemptive Scheduling Using Synchronization Synthesis

Pavol Cerný, Edmund M. Clarke, Thomas A. Henzinger, Arjun Radhakrishna, Leonid Ryzhyk, Roopsha Samanta, Thorsten Tarrach

Introduction

Concurrent programming remains one of the most challenging aspects of software development. The primary difficulty arises from the preemptive nature of modern schedulers, which can interrupt a thread at any point, potentially leading to race conditions and atomicity violations. While developers often have a "mental model" of how their code should behave—typically assuming a non-preemptive environment where operations are atomic—translating this into a safe, preemptive implementation requires manual insertion of locks and complex assertions.

This paper introduces Liss, a synthesis tool designed to bridge this gap. Liss allows developers to write code under the assumption of a "friendly" non-preemptive scheduler. It then automatically synthesizes the necessary synchronization primitives to ensure that the program's behavior under a "hostile" preemptive scheduler remains consistent with its non-preemptive specification.

Methodology: Synthesis via Abstraction

The core innovation of Liss lies in using non-preemptive semantics as an implicit specification. If a sequence of external behaviors (such as I/O operations) is possible under a non-preemptive scheduler, it is defined as correct. The goal is to ensure the set of preemptive behaviors is a subset of these "correct" non-preemptive behaviors.

Data-Oblivious Abstraction

To handle the state-space explosion inherent in concurrency verification, Liss employs a data-oblivious abstraction. This approach tracks the types of memory accesses (reads and writes) and control flow choices while ignoring actual data values. This is particularly effective for systems code, such as device drivers, where synchronization logic is often independent of the specific data being processed.

Standard operational semantics for the source language.

The transition from standard semantics (Figure 1) to instrumented semantics (Figure 2) is crucial. While standard semantics track value changes (e.g., $e[v/\mathcal{V}[v]] = k$), the instrumented version focuses on the trace of actions $\alpha$.

Instrumented semantics used for data-oblivious abstraction in Liss.

Language Inclusion and Iterative Synthesis

Liss reduces the verification problem to language inclusion modulo independence. It uses Mazurkiewicz traces to define equivalence between interleavings of independent operations. Since general language inclusion for these traces is undecidable, the authors implemented a bounded antichain algorithm to search for counterexamples within a specific bound of "out-of-order" executions.

When a "bad" interleaving (a counterexample) is found, Liss generalizes the pattern and applies inference rules to suggest a fix, such as wrapping a critical section in a lock. This process iterates until the program is proven safe under the specified bounds.

Evaluation and Results

Liss was evaluated against several benchmarks, including the ConRepair suite of Linux driver microbenchmarks, a USB-to-Serial driver, and a complex TI AR7 CPMAC Ethernet driver.

  • Bug Discovery: Liss successfully identified and fixed nearly all known race conditions in the benchmarks. Notably, it discovered a new race condition in the usb-serial driver that had been missed by previous state-of-the-art tools like ConRepair, primarily because ConRepair relied on manual assertions that were incomplete.
  • Performance: The tool demonstrated significant efficiency gains. For the usb-serial benchmark, Liss completed synthesis in 82 seconds, compared to the 20 minutes required by the assertion-based ConRepair.
  • Scalability: Liss successfully handled the CPMAC Ethernet driver, a benchmark of significantly higher complexity than those typically processed by existing synchronization synthesis tools.

Discussion and Limitations

While Liss significantly lowers the barrier to formal concurrency verification by eliminating the need for manual assertions, it has some limitations. It currently lacks sophisticated alias analysis and does not support recursion. Furthermore, while it employs heuristics to avoid deadlocks, it does not provide a formal guarantee of deadlock-freedom. In rare cases where synchronization depends strictly on data values, manual refinement of the abstraction is still required.

Future work aims to integrate automatic abstraction refinement and extend the synthesis engine to provide formal guarantees against deadlocks.

Summary updated

BibTeX
@article{cerny2017from,
  author = {Pavol Cerný and Edmund M. Clarke and Thomas A. Henzinger and Arjun Radhakrishna and Leonid Ryzhyk and Roopsha Samanta and Thorsten Tarrach},
  title = {{From Non-preemptive to Preemptive Scheduling Using Synchronization Synthesis}},
  journal = {Formal Methods Syst. Des.},
  year = {2017},
  doi = {10.1007/s10703-016-0256-5},
}
Figure