Multi-Core Programming: Increasing Performance through Software Multithreading

Debugging multi-threaded applications can be a challenging task. The increased complexity of multi-threaded programs results in a large number of possible states that the program may be in at any given time. Determining the state of the program at the time of failure can be difficult; understanding why a particular state is troublesome can be even more difficult. Multi-threaded programs often fail in unexpected ways, and often in a nondeterministic fashion. Bugs may manifest themselves in a sporadic fashion, frustrating developers who are accustomed to troubleshooting issues that are consistently reproducible and predictable. Finally, multi-threaded applications can fail in a drastic fashion deadlocks cause an application or worse yet, the entire system, to hang. Users tend to find these types of failures to be unacceptable.
This chapter examines general purpose techniques that are useful when debugging multi-threaded applications. Intel has developed a number of tools, including the Intel Thread Checker, the Intel Thread Profiler, and the Intel Debugger that help debug and profile multi-threaded applications. These tools are discussed in Chapter 11.
Regardless of which library or platform that you are developing on, several general principles can be applied to debugging multi-threaded software applications.
The first technique for eliminating bugs in multi-threaded code is to avoid introducing the bug in the first place. Many software defects can be prevented by using proper software development practices. [1] The later a problem is found in the product development lifecycle, the more...