Download Sun Studio 12: Thread Analyzer User's Guide

Transcript
Contents
Preface .....................................................................................................................................................5
1
What is the Thread Analyzer and What Does It Do? ........................................................................11
1.1 Getting Started With the Thread Analyzer ................................................................................ 11
1.2 What is a Data Race? ..................................................................................................................... 11
1.3 What is a Deadlock? ...................................................................................................................... 12
1.4 The Thread Analyzer Usage Model ............................................................................................. 12
2
The Data-Race Tutorial .......................................................................................................................15
2.1 Tutorial Source Files ..................................................................................................................... 15
2.1.1 Complete Listing of omp_prime.c .................................................................................... 15
2.1.2 Complete Listing of pthr_prime.c .................................................................................. 17
2.2 Creating Experiments ................................................................................................................... 21
2.2.1 Instrument the Source Code .............................................................................................. 21
2.2.2 Create a Data-Race Detection Experiment ...................................................................... 22
2.2.3 Examine the Data-Race Detection Experiment .............................................................. 22
2.3 Understanding the Experiment Results ...................................................................................... 23
2.3.1 Data Races in omp_prime.c ............................................................................................... 23
2.3.2 Data Races in pthr_prime.c ............................................................................................. 26
2.4 Diagnosing the Cause of a Data Race .......................................................................................... 29
2.4.1 Check Whether or Not the Data Race is a False Positive ................................................ 29
2.4.2 Check Wether or Not the Data Race is Benign ................................................................ 30
2.4.3 Fix the Bug, Not the Data Race .......................................................................................... 30
2.5 False Positives ................................................................................................................................. 33
2.5.1 User-Defined Synchronizations ....................................................................................... 34
2.5.2 Memory That is Recycled by Different Threads .............................................................. 35
2.6 Benign Data-Races ........................................................................................................................ 36
3