5.8 Using the Thread Analyzer

The Oracle Solaris Studio Thread Analyzer is an advanced tool for application optimization that is designed to help you detect and analyze race conditions and deadlocks in multithreaded applications.

Data races can cause incorrect or unpredictable results, and they can occur arbitrarily far way from where a problem appears to occur. Data races occur under the following conditions:

Deadlock conditions occur when one thread is blocked waiting on a resource held by a second thread, while the second thread is blocked waiting on a resource held by the first (or an equivalent situation where more than two threads are involved).

To instrument the source code for the detection of data race and deadlock issues, first compile the code with the -xinstrument=datarace flag, It is recommended that you also set the -g flag and that you specify no optimization level to help ensure that information about line numbers and call stacks is returned correctly.

You then execute the resulting application code using the collect -r race or collect -r deadlock command, which collect runtime information for the detection of data races or deadlocks during the execution of the process.

$ collect -r race app params
$ collect -r deadlock app params 

Finally, load the results of the experiment into the Thread Analyzer to identify any data race or deadlock conditions.