Previous Topic: Resources and Resource Locks

Next Topic: Primary Names

Resource Groups

To explain the concept of a resource group, take the previous example of a file record, in which a procedure uses resource locking to guarantee exclusive access to a file record for the purpose of updating it, without having to worry about any other process changing the record at the same time. In this example, the resource could be a name that represents the entire file; in other words, you could organize your procedure to have exclusive read/write access to a whole database.

Alternatively, and probably in preference, you would like other processes to continue to have access to the file as a whole, as long as they could not access the specific record that your process is updating. To achieve this, you would assign a resource primary name to represent the file (UDB), and 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 UDB containing NCP configuration data keyed by line name, you might assign a primary name of CONFIG to represent the UDB itself and use the line name as a minor name to represent each line record as a resource within the UDB. To retrieve information about a line, your procedure first obtains exclusive access to the appropriate line record resource by requesting exclusive control of the appropriate primary/minor name resource lock.

In this example, your procedure would execute the following &LOCK statement to gain exclusive permission to process the record on the UDB that contains information about line 23:

&LOCK TYPE=EXCL PNAME=CONFIG MNAME=LINE23

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 line 23:

&LOCK TYPE=EXCL PNAME=CONFIG MNAME=XYZ

In this example, the primary name (CONFIG) represents a resource group. The combination of the primary name and a minor name identifies a resource within the group.