Analyzing Program Performance With Sun WorkShop

LockLint Overview

When analyzing locks and how they are used, LockLint detects a common cause of data races: failure to hold the appropriate lock while accessing a variable.

Table 5-1, Table 5-2, and Table 5-3 list the routines of the Solaris and POSIX libthread APIs recognized by LockLint.

Table 5-1 Reader -Writer Locks

Solaris 

Kernel (Solaris only) 

rw_rdlock, rw_wrlock rw_unlock rw_tryrdlock, rw_trywrlock

rw_enter

rw_exit

rw_tryenter

rw_downgrade

rw_tryupgrade

Table 5-2 Condition Variables

Solaris 

POSIX 

Kernel (Solaris only) 

cond_broadcast

cond_wait

 

 

cond_timedwait

cond_signal

pthread_cond_broadcast

pthread_cond_wait

 

 

pthread_cond_timedwait

 

pthread_cond_signal

cv_broadcast

cv_wait

cv_wait_sig

cv_wait_sig_swap

cv_timedwait

cv_timedwait_sig

cv_signal

Table 5-3 Mutex (Mutual Exclusion) Locks

Solaris 

POSIX 

Kernel (Solaris only) 

mutex_lock

mutex_unlock

mutex_trylock

pthread_mutex_lock

pthread_mutex_unlock

pthread_mutex_trylock

mutex_enter

mutex_exit

mutex_tryenter

Additionally, LockLint recognizes the structure types shown in Table 5-4.

Table 5-4 Lock Structures
 Solaris POSIX Kernel (Solaris only)
 mutex_t pthread_mutex_t kmutex_t
 rwlock_t  krwlock_t

LockLint reports several kinds of basic information about the modules it analyzes, including:

LockLint provides subcommands for specifying assertions about the application. During the analysis phase, LockLint reports any violation of the assertions.


Note -

Add assertions liberally, and use the analysis phase to refine assertions and to make sure that new code does not violate the established locking conventions of the program.