A method and several variants for using information about the scope of
access of objects acted upon by mutual exclusion, or mutex, locks to
transform a computer program by eliminating locking operations from the
program or simplifying the locking operations, while strictly performing
the semantics of the original program. In particular, if it can be
determined by a compiler that the object locked can only be accessed by a
single thread it is not necessary to perform the "acquire" or "release"
part of the locking operation, and only its side effects must be
performed. Likewise, if it can be determined that the side effects of a
locking operation acting on a variable which is locked in multiple threads
are not needed, then only the locking operation, and not the side effects,
needs to be performed. This simplifies the locking operation, and leads to
faster programs which use fewer computer processor resources to execute;
and programs which perform fewer shared memory accesses, which in turn not
only causes the optimized program, but also other programs executing on
the same computing machine to execute faster. The method also describes
how information about the semantics of the locking operation side effects
and the information about the scope of access can also be used to
eliminate performing the side effect parts of the locking operation,
thereby completely eliminating the locking operation. The method also
describes how to analyze the program to compute the necessary information
about the scope of access. Variants of the method show how one or several
of the features of the method may be performed.