Oracle® Solaris Studio 12.4: Thread Analyzer User's Guide

Exit Print View

Updated: December 2014
 
 

Create a Deadlock-Detection Experiment

Use the collect command with the –r deadlock option. This option creates a deadlock-detection experiment during the execution of the program.

For this tutorial, create a deadlock-detection experiment named din_philo.1.er using the following command:

% collect -r deadlock -o din_philo.1.er din_philo

The collect command accepts the following options, which are useful when creating a deadlock-detection experiment:

terminate

If an unrecoverable error is detected, terminate the program.

abort

If an unrecoverable error is detected, terminate the program with a core dump.

–continue

If an unrecoverable error is detected, enable the program to continue.

The default behavior is terminate.

You can use any of the previous options with the collect command to get the behavior you want. For example, to cause the program to terminate with a core dump when an actual deadlock occurs use the following collect command.

% collect -r deadlock,abort -o din_philo.1.er din_philo

To cause the program to hang when an actual deadlock occurs, use the following collect command:

% collect -r deadlock,continue -o din_philo.1.er din_philo

You can increase the likelihood of detecting deadlocks by creating several deadlock-detection experiments. Use a different number of threads and different input data for the various experiments. For example, in the din_philo.c code, you could change the values in the following lines:

    13  #define PHILOS 5
    14  #define DELAY 5000
    15  #define FOOD 100

You could then compile as before and collect another experiment.

See collect(1) and collector(1) man pages for more information.