DCE Application Programming Guide
Building, Running, and Debugging NonStop DCE 
Applications
HP NonStop DCE Application Programming Guide—429551-003
4-8
Debugging With Threads
Difficulty in Debugging Multiple Application Threads
Debugging multithreaded applications can be difficult because of the interaction and 
synchronization of the threads.
The simplest multithreaded applications to debug are those that have no 
interdependent threads. Many standard DCE servers are in this category (see the 
discussion of Single Versus Multiple Application Threads on page 3-13). For these 
applications, the application code can be tested using a single application thread. For 
example, server manager code can be unit-tested by using a single client program that 
issues one RPC at a time. Once the program passes its functional tests, it can be 
tested using multiple concurrent clients and multiple application call threads.
Even in this simplest case, implicit dependencies can exist between the application 
threads because they share the same process environment. These dependencies can 
be subtle and might result in observable effects only under unusual conditions, such as 
error handling. Find these problems during design and code reviews can be easier 
than finding them during unit-testing or system-testing.
Implicit dependencies also occur when applications use libraries that return pointers to 
static data or that maintain context across calls into the library. Application threads can 
also interfere with each other implicitly as a result of using process-blocking calls, not 
yielding the processor, or corrupting process memory. These issues are discussed at 
length in Threading Considerations for NonStop DCE Applications on page 3-4.
Debugging a program becomes more complex as the amount of synchronization 
increases. Types of application synchronization include using mutexes to reserve 
access to a shared resource and using condition variables to wait for a shared 
resource to be in a certain state. When these techniques are used, the programs must 
be carefully designed with the threading model in mind.










