Exercise 1.3: Identifying a thread bottleneck

Before you begin, you must complete Exercise 1.2 Collecting thread data.

Finding thread bottlenecks using the Thread View

The Thread View displays the status of all the threads in your application, and explicitly indicates thread deadlocks and contentions.

To find bottlenecks:

  1. In the Profiling Monitor, right-click the Profiling resource, and then select Open With > Thread View. The Thread View opens. It looks something like this:

    Screenshot of the Thread View showing the results for this profiling run, as described in the following text.

    The vertical arrows between threads are what interest us. An arrow indicates that one thread (the thread in which the arrow originates) is waiting for another thread (the thread to which the arrow is pointing) to release a lock.

  2. The arrows are too close to each other to be easily distinguished. To see them better, switch from the default linear time scale to a weighted time scale by clicking the Switch to Compressed Time Scale button . The Compressed Time Scale compresses the time segments during which no significant thread action occurs. The display changes to something like this:

    Screenshot showing the distribution of the arrows after the time scale is changed to 'Compressed.'

  3. Interpret the Thread View as follows:
    1. Note that soon after the program starts, four philo* threads are created. All of them run, then sleep, then run again briefly. When the program terminates, all of them have changed to a Waiting for Lock state.
      Note: A distinct "Sleep" state cannot be displayed on some systems.
    2. The philo* threads are waiting for a lock from other philo* threads that are also waiting for a lock. In this case, we have a deadlock: The program reaches an impasse and cannot continue.
      Note: You can see specific information about lock requests by pausing your cursor over the thread segment that is waiting for a lock. This displays a tool-tip that specifies the name of the lock and identifies the thread that is holding the lock (the "Locking Thread").
  4. You can see detailed information about thread segments in the Properties view. To display the view, select Windows > Show View > Properties. Select a thread segment to display its properties.

You now understand why this deadlock occurs. You are ready to begin Exercise 1.4: Resolving the thread bottleneck.

Terms of use | Feedback
(C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.