NET/MASTER Network Control Language (NCL) Programmer's Guide
Synchronizing Access to Resources
Advanced NCL Programming
106160 Tandem Computers Incorporated 18–19
It is important to understand that it is not the data itself that is protected by the lock
mechanism, only the resource that controls access to the data. In a UDB, for example,
it is not a record that is locked—it is the resource that controls access to the data. If
controlled access to an item of data is required, then all NCL processes that change
that data must gain access to the lock before updating it.
Resource Groups To explain the concept of a resource group, take the example of a record in a UDB. In
this example, an NCL process can use resource locking to guarantee exclusive access to
the record to update it without having to worry about any other NCL processes
changing the record at the same time. In this example, the resource may be a name
that represents the entire file.
You could organize your NCL process to have exclusive access to a whole UDB. On
the other hand, you may want other NCL processes to continue to have access to the
UDB, as long as they are not able to access the specific record that your NCL process is
updating.
To achieve this flexibility, you would assign a resource primary name to represent the
UDB itself. You would then decide on a naming convention that allows individual
records within the file to be identified by a minor name.
For example, if you have a key-sequenced UDB with a surname as the primary key,
you could assign a primary name of MYFILE to represent the UDB itself. You could
use the surname as a minor name to represent each record as a resource within the
UDB.
To retrieve information about a record, your NCL process first obtains exclusive access
to the appropriate record resource by requesting exclusive control of the appropriate
primary/minor name resource lock. In this example, therefore, your NCL process
would execute the following statement to gain exclusive permission to process the
record on the UDB that contains information about SURNAME1:
LOCK TYPE=EXCL PNAME=MYFILE MNAME=SURNAME1
Alternatively, you could code the following statement if your naming convention for
resource locks uses XYZ to identify the record on the database that describes the
configuration of surname SURNAME1:
LOCK TYPE=EXCL PNAME=CONFIG MNAME=XYZ
In this example, the primary name MYFILE represents a resource group. The
combination of the primary name and a minor name identifies a resource within the
group.
Primary Names
The primary name is the part of the resource name that uniquely identifies the
resource group. It is a character string from 1 through 250 characters long.
Logically, the primary name represents the root of a (potential) two-level hierarchy,
below which one or more dependent minor names can exist.