If you suspect a dead end, do ps aux | grep <exe name> ps aux | grep <exe name> , if the output of PROCESS STATE CODE is D (Uninterrupted sleep) means that it is a dead end. Because, as @daijo explained, let's say you have two streams T1 and T2 and two critical sections, each of which is protected by semaphores S1 & S2 , then if T1 gets S1 and T2 gets S2 , and after that they try to get another the lock, before abandoning what they have already completed, this will lead to a deadlock, and when ps aux | grep <exe name> ps aux | grep <exe name> PROCESS STATE CODE will be D (i.e. Uninterrupted sleep).
Instruments:
Valgrind, Lockdep (Linux kernel utility)
Check this link for deadlock types and how to avoid them: http://cmdlinelinux.blogspot.com/2014/01/linux-kernel-deadlocks-and-how-to-avoid.html
source share