Good Lock Strategy

This tutorial demonstrates using the various Thread Validator views to analyse a correctly performing application. This tutorial also introduces the launch wizard.

  • Launch the sample application. Click on the launch icon on the toolbar.
    Thread Validator launch icon
  • The Launch application wizard is displayed.
    Thread Validator launch wizard
  • Select the sample application nativeExample.exe using the Browse… button.
  • Click the Next button to move to the 2nd page of the wizard.
    Thread Validator launch wizard
  • Leave the settings as the default settings.
  • Click the Next button to move to the 3rd page of the wizard.
    Thread Validator launch wizard
  • Leave the settings as the default settings.
  • Click the Next button to move to the 4th page of the wizard.
    Thread Validator launch wizard
  • Click the Start Application button to launch the application.
  • The nativeExample.exe application is started.
    Thread Validator native example application
  • Whilst Thread Validator is instrumenting the application various progress dialogs are displayed. The display of Thread Validator updates to show information about each thread, critical section and WaitForXXX() call.
    Thread Validator display
  • Using nativeExample’s Test menu, choose Good lock strategy example. This menu command starts three threads modifying some counters. The counters are displayed on the nativeExample user interface. The example threading code has correctly coded critical sections which always enter and leave the locks in the same order in each thread.
  • View the Locks tab to see all critical sections. You will see some critical section Lock counts increasing as the threads execute. Critical sections that are contended between the threads will causes the Contention count to increase. Critical sections that are contended will be highlighted (the default colour is yellow). The image shown below shows three waiting critical sections.
    Thread Validator good lock strategy
  • View the Per Thread Locks tab to see all critical sections on a per-thread basis.. The highlighting colours for this tab are the same as for the Locks tab. Notice that there are entries for each critical section used by a thread on a per-thread basis – this allows you to see how many times a particular thread has used a given critical section. The image shown below shows three locked critical sections and two waiting critical sections.
    Thread Validator good lock strategy
  • View the Current Locks tab to see all critical sections that are currently locked or waiting. The image shown below shows four locked critical sections.
    Thread Validator good lock strategy
  • Close the Application using the File menu’s Exit command.
  • The various tabs will display the last known state of the critical sections and waits prior to the application finishing.
  • Any errors identified during shutdown will be added to the state for each critical section and the displays updated to reflect this.

Fully functional, free for 30 days