Operating in LKE

A LOCK argument may contain any subscripted or unsubscripted M name including a name without a preceding caret symbol (^). Because they have the appearance of local variable names, resource names with no preceding caret symbol (^) are commonly referred to as "local LOCKs," even though these LOCKs interact with other processes.

The GT.M run-time system records LOCK information in memory associated with the region holding the global of the same name. However, GT.M does not place LOCKs in the database structures that hold the globals. Instead a "LOCK database" is associated with the database. Only the M commands LOCK, ZALLOCATE, and ZDEALLOCATE, and the LKE utility access the information in the "LOCK database."

When a process leaves M, GT.M normally releases any LOCKs or ZALLOCATEs held by that process. If a GT.M process terminates abnormally, or if the system "crashes" while a GT.M process is active, GT.M cannot perform normal clean-up. However, as soon as any other process waits several seconds for a LOCK, GT.M automatically clears the "orphaned" LOCK.

Functions of the M Lock Utility (LKE)

The two primary functions of the M Lock Utility (LKE) are:

  • SHOW all or specified LOCKs currently active

  • CLEAR all or specified LOCKs currently active

When debugging an M application, you may use LKE to identify and clear a possible deadlock situation, that is, two or more processes have LOCKs and are waiting to add resource names LOCKed by the other(s).


            Process 1      Process 2

             LOCK A

                            LOCK B

                            LOCK  +A

             LOCK  +B
             

Process 1 has A LOCKed and attempts to LOCK B. Process 2 has B LOCKed and attempts to LOCK A. Because these processes do not release their current LOCKs before adding additional LOCKs, nor do they provide a timeout to detect the problem, they are deadlocked. Neither process can proceed normally. You can use LKE to release one of the LOCKs so both processes may execute. However, because releasing a LOCK may cause the process to violate its design assumptions, terminating one process is generally a safer way to break the deadlock.

[Note]

The occurrence of a deadlock in a GT.M application usually indicates an error in the design or implementation of an application.

Invoking and Exiting LKE

The default installation procedure places the LKE utility package in a directory specified by the logical name GTM$DIST The installation also creates command files that define GTM$DIST and assign the symbol LKE to be the foreign command, $GTM$DIST:LKE.

Invoke LKE using the GT.M symbol LKE at the DCL shell prompt. If this does not work, consult your system manager to investigate setup and file access issues.

LKE requires that the environmental variable gtmgbldir be defined.

        $ LKE
        
        

When LKE is ready to accept commands, it displays the LKE> prompt. When additional information is entered on the DCL command line after the LKE command, LKE processes the additional information as its command.

        $ LKE SHOW 
        
        

This command displays all current LOCKs and then returns to the DCL prompt. To leave LKE, enter the EXIT command at the LKE>prompt.

LOCKs and Global Directories

GT.M distributes the LOCK database within space associated with the database files identified by the Global Directory (GD). The Global Directory Editor (GDE) enables you to create and maintain Global Directories.

GT.M maps LOCKs of resource names starting with a caret symbol (^) to the database file used to map variables with the same name. If the Global Directory maps the name ^A to file A.DAT, GT.M maps all LOCKs on resource name ^A to A.DAT.

GT.M maps LOCKs on names not starting with a caret symbol (^) to the region of the database specified with the GDE command LOCKS /REGION. By default, GDE creates Global Directories mapping "local" LOCKs to the region DEFAULT.

  • "Globals" automatically intersect for all users of the same data in any database file, because GT.M associates the ^LOCKs with the same file as the data of the same name.

  • "Local" LOCK intersections are dependent on the Global Directory, because users may access the database through different Global Directories.

Establishing a Global Directory

LKE uses the logical name GTM$GBLDIR to identify the active Global Directory. Define GTM$GBLDIR using the DCL command DEFINE. The system manager may define GTM$GBLDIR in a GROUP or SYSTEM logical name table, allowing many users access to the logical name. Individual users define GTM$GBLDIR in their LOGIN.COM or other command files.

            $ DEFINE GTM$GBLDIR PROD.GLD