Tech Report CS-96-04

Race-Condition Detection in Parallel Computation with Semaphores

Philip N. Klein Hsueh-I Lu and Robert H. B. Netzer

January 1996


We address a problem arising in debugging parallel programs, detecting race conditions in programs using semaphores for synchronization. It is NP-complete to detect race conditions in programs that use many semaphores. We show in this paper that it remains NP-complete even if the programs are allowed to use only two semaphores.

For the case of single semaphore, Lu, Klein, and Netzer gave the previously only-known polynomial-time algorithm that runs in time $O(n^{1.5}p)$, where $p$ is the number of processors and $n$ is the total number of semaphore operations executed. Their algorithm, however, detects only a special class of race conditions. In this paper we cope with the general race-condition detection problem and give an $O(np\log n)$-time algorithm. The output of our algorithm is a compact representation from which one can determine in constant time whether a race condition exists between two given operations.

(complete text in pdf or gzipped postscript)