Go to main content
Oracle® Developer Studio 12.6: Thread Analyzer User's Guide

Exit Print View

Updated: June 2017
 
 

Getting Started With Thread Analyzer

Thread Analyzer can show data races and deadlocks in experiments that you can create specifically for examining these types of errors, as explained in this document.

Thread Analyzer is a specialized view of Performance Analyzer that is designed for examining thread analysis experiments. See Thread Analyzer Interface for more information.

What is a Data Race?

    Thread Analyzer detects data races that occur during the execution of a multithreaded process. A data race occurs when all of the following are true:

  • Two or more threads in a single process access the same memory location concurrently

  • At least one of the accesses is for writing

  • The threads are not using any mutual exclusive locks to control their accesses to that memory

When these three conditions hold, the order of accesses is non-deterministic, and the computation might give different results from run to run depending on that order. Some data races might be benign (for example, when the memory access is used for a busy-wait), but many data races are bugs in the program.

Thread Analyzer works on a multithreaded program written using the POSIX thread API, Oracle Solaris thread API, OpenMP, or a mix of these.

What is a Deadlock?

Deadlock describes a condition in which two or more threads are blocked forever because they are waiting for each other. There are many causes of deadlocks. Thread Analyzer detects deadlocks that are caused by the inappropriate use of mutual exclusion locks. This type of deadlock is commonly encountered in multithreaded applications.

A process with two or more threads can deadlock when all of the following conditions are true:

  • Threads that are already holding locks request new locks

  • The requests for new locks are made concurrently

  • Two or more threads form a circular chain in which each thread waits for a lock which is held by the next thread in the chain

Here is a simple example of a deadlock condition:

  • Thread 1 holds lock A and requests lock B

  • Thread 2 holds lock B and requests lock A

A deadlock can be of two types: A potential deadlock or an actual deadlock. A potential deadlock does not necessarily occur in a given run, but can occur in any execution of the program depending on the scheduling of threads and the timing of lock requests by the threads. An actual deadlock is one that occurs during the execution of the program. An actual deadlock causes the threads involved to hang, but might cause the whole process to hang.