Contents
The Thread Analyzer detects is a Sun Studio tool that detects data races and (potential and actual) deadlocks that occur during a multi-threaded process.
The Thread Analyzer is available on the following hardware and operating systems:
A Getting Started Guide,
a tutorial on using the Thread
Analyzer for data race detection, and , a tutorial on using the Thread Analyzer for
deadlock detection have been prepared for this preliminary
release. There is also a general
Thread Analyzer Information Page. A data race occurs when two or more threads in a process access the same memory location concurrently, at least one of the accesses is for writing, and the threads are not using any exclusive locks to control their accesses to that memory. A data race may result in non-deterministic program behavior and incorrect execution. Bugs caused by data races are notoriously difficult to detect by hand. The Thread Analyzer keeps track of data accesses in a multi-threaded program at runtime, and reports data races that have been encountered. By automatically detecting data races, the tool relieves the programmer from the laborious task of debugging the program and eases the task of multi-threaded programming. Deadlock describes a condition where two or more threads are blocked (hang) forever, waiting for each other. Suppose we have a process with two or more threads. A deadlock occurs when the following three conditions hold:
Thread 1: holds lock A, requests lock B A deadlock can be of two types: A "potential deadlock" or an "actual deadlock". A potential deadlock is a deadlock that did not occur in a given run, but can occur in different runs of the program depending on the timings of the requests for locks by the threads. An actual deadlock is one that actually occured in a given run of the program. An actual deadlock causes the threads involved to hang, but may or may not cause the whole process to hang. Yes. Use collect -r all or collect -r race,deadlock to create an experiment for both data race and deadlock detection. The program needs to be instrumented for data race detection. Refer to the Getting Started Guide for more information. Yes. You can instrument your program for data race detection by compiling it with the -xinstrument=datarace compiler option. Refer to the Getting Started Guide for more information. No. You do not need to instrument your program for deadlock detection. The Thread Analyzer detects data races at runtime. At compile-time, the compiler inserts instrumentation code into the executable, so data races can be detected at runtime. To detect data races at runtime, run the instrumented executable using the collect command. The Thread Analyzer detects (potential and actual) deadlocks at runtime, by keeping track of all the lock/unlock operations by the threads. No instrumentation of the code is required for deadlock detection. Simply run the executable using the collect command. The Thread Analyzer can detect data races that occur in code that is written using the POSIX thread API, the Solaris Operating System(R) thread API, OpenMP directives, Sun parallel directives, Cray(R) parallel directives, or a mix of these. The Thread Analyzer can detect (potential and actual) deadlocks that occur in code that is written using the POSIX thread API, the Solaris Operating System(R) thread API, OpenMP directives, Sun parallel directives, Cray(R) parallel directives, or a mix of these. Not yet. The Thread Analyzer currently only detects data races between different threads spawned from a single process. No. The Thread Analyzer detects data races at runtime. Since the exact runtime behavior of a program depends on a variety of factors (input data-set used, the scheduling of threads by the Operating System, etc.), not all data races in a program may be detected. Note that the Thread Analyzer is not a verification tool, but is a checking tool. If the Thread Analyzer does not report any races, that does not imply that the program is race-free. Use the Thread Analyzer with different numbers of threads and with different input data-sets and repeat experiments with a single data set to maximize the tool's chance of detecting data races. The exact run-time behavior of a program depends on a variety of factors, including the scheduling of threads by the Operating System. The data race detection module of the Thread Analyzer uses heuristics to improve performance. As a result, the Thread Analyzer may not report all data races that it can detect. The Thread Analyzer guarantees, however, that if it detects that a memory location is involved in one or more data races, then it will report at least one of those data races. In some cases, the Thread Analyzer may report data races that never actually occur in the program. These are called false positives, which usually happen when a user-implemented synchronization is used or when memory is recycled between threads. For example, if your code includes hand-coded assembly that implements spin locks, the Thread Analyzer will not recognize these synchronization points. Please see the a tutorial on Using the Thread Analyzer for a detailed description of false positives and examples of how to remove them through user API calls. libtha.so is a library that satisfies the entry points for the data race-detection instrumentation calls and user API calls. It is linked automatically when a program is compiled and linked with -xinstrument=datarace. See the libtha(3) man page for more information.
This is a limitation of Express 2 build. Use Express 3 or later
build There is no hard and fast rule to determine this. You need to inspect the code of the program, and determine whether a data race is benign or not based on the logic involved, the type of variable, the machine architecture, etc.
Yes, though the Performance Analyzer displays all of the traditional
performance analysis tabs as well as the new Races, Dual Source, and
Race Detail tabs. The
You are using an older version of Sun Studio that does not support the
Thread Analyzer. Check the version of Sun Studio that you are using by
typing: cc -Version
You are using an older version of Sun Studio that does not support the Thread Analyzer. Check the version of Sun Studio that you are using by entering er_print -V. You must use a version that is no older then June 2006. You are using an older version of Sun Studio that does not support the Thread Analyzer. Check the version of Sun Studio that you are using by entering collect -V. You must use a version that is no older then June 2006. The best resource for sharing your feedback with the Thread Analyzer engineers and users is by reading and posting to the Sun Studio Tools Forum. You may find that your question has already been answered. |
| |||||
|
| ||||||||||||