Analyzing Program Performance With Sun WorkShop

assert

assert has the following syntax:

assert side effect

mutex

acquired in 

func ...

assert side effect

rwlock [read]

acquired in 

func ...

assert side effect

lock

released in 

func ...

assert side effect

rwlock

upgraded in 

func ...

assert side effect

rwlock

downgraded in 

func ...

assert mutex|rwlock

protects 

 

var ...

assert mutex

protects 

 

func ...

assert rwlock

protects 

[reads in] 

func ...

assert order

 

 

lock lock ...

assert read only

 

 

var ...

assert rwlock

covers 

 

lock ...

These subcommands tell LockLint how the programmer expects locks and variables to be accessed and modified in the application being checked. During analysis any violations of such assertions are reported.


Note -

If a variable is asserted more than once, only the last assert takes effect.


assert side effect

A side effect is a change made by a function in the state of a lock, a change that is not reversed before the function returns. If a function contains locking side effects and no assertion is made about the side effects, or the side effects differ from those that are asserted, a warning is issued during the analysis. The analysis then continues as if the unexpected side effect never occurred.


Note -

There is another kind of side effect called an inversion. See "Lock Inversions", and the locks or funcs subcommands, for more details.


Warnings are also issued if the side effects produced by a function could differ from call to call (for example, conditional side effects). The keywords acquired in, released in, upgraded in, and downgraded in describe the type of locking side effect being asserted about the function. The keywords correspond to the side effects available via the threads library interfaces and the DDI and DKI Kernel Functions (see mutex(3T), rwlock(3T), mutex(9F) and rwlock(9F)).

The side effect assertion for rwlocks takes an optional argument read; if read is present, the side effect is that the function acquires read-level access for that lock. If read is not present, the side effect specifies that the function acquires write-level access for that lock.