Multithreaded programming is notoriously difficult to get right. A key problem
is non-determinism, which complicates debugging, testing, and reproducing
errors. One way to simplify multithreaded programming is to enforce
deterministic execution, but current deterministic systems for C/C++ are
incomplete or impractical. These systems require program modification, do not
ensure determinism in the presence of data races, do not work with
general-purpose multithreaded programs, or run up to 8.4X slower than
pthreads.
This paper presents Dthreads, an efficient deterministic multithreading
system for unmodified C/C++ applications that replaces the pthreads library.
Dthreads enforces determinism in the face of data races and deadlocks.
Dthreads works by exploding multithreaded applications into multiple
processes, with private, copy-on-write mappings to shared memory. It uses
standard virtual memory protection to track writes, and deterministically orders
updates by each thread. By separating updates from different threads,
Dthreads has the additional benefit of eliminating false sharing.
Experimental results show that Dthreads substantially outperforms a
state-of-the-art deterministic runtime system, and for a majority of the
benchmarks evaluated here, matches and occasionally exceeds the performance of
pthreads.