Using Locks within Transactions

Examples of Lock

Within transactions LOCKs are used by GT.M to ensure the ability to serialize. There is no guarantee, however, that attempts by other processes to examine LOCKs held with a transaction will produce the same results as when LOCKs are outside of a transaction. In other words, LOCKs within transactions should never be used as simple semaphores.

The LOCK command locks a specified resource name that controls a tree structured name space. Outside of transactions when one process in an environment acquires a LOCK or a ZALLOCATE on a named resource, no other GT.M process in that environment can LOCK a resource with an "overlapping" name until the first process releases the LOCK that it holds.

For information on the use of LOCKs within transactions, refer to the chapter on "General Language Features of M" in this manual.

LOCK Command Operation Summary

COMMANDS

ISSUED

RESULTING

LOCKS

COMMENTS

L

none

Remove all prior locks.

L A

A

Remove prior locks then lock A.

L

L +A

A

This sequence is equivalent to L A

L A

L -A

none

Remove prior locks before locking A, then remove lock on A. This is equivalent to L A L

L A

L +A

L -A

A

Remove prior locks before locking A, increment lock on A without releasing prior lock on A, decrement lock on A without releasing prior lock on A.

L A

L +B

A,B

Remove prior locks before locking A, then lock B without releasing A.

L A,B

B

Remove prior locks before locking A, unlock A, then lock B.

L (A,B)

A,B

Remove prior locks before locking A and B simultaneously.

L A

L +B

L +C

A,B,C

Remove prior locks before locking A, lock B without releasing A, lock C without releasing A and B

L A

L +(B,C)

A,B,C

Remove prior locks before locking A, lock B and C simultaneously without releasing A.

L (A,B,C)

L -B

L -C

A

Remove prior locks before locking A, B, and C simultaneously, remove lock on B without releasing A and C, remove lock on C without releasing A.

L (A,B,C)

L -(B,C)

A

Remove prior locks before locking A, B, and C simultaneously, remove lock on B and C without releasing A.

L (A,B)

L -B

A

Remove prior locks before locking A and B simultaneously, remove lock on B without releasing A.