Generic Locking and Deadlock-Prevention with C++

Concurrent programming with threads heavily relies on locks. The locks provided by most threading systems are rather basic and suffer from a variety of problems. This paper addresses some of them, namely deadlocks, lack of exception-safety, and their procedural style. We describe higher-level locks that can be assembled from the more basic ones. Throughout the paper, we refer to C++ and OpenMP for parallelization, but most of the functionality is generic and independent from OpenMP. This work is part of the AthenaMP project.