OpenTP1 Version 7 Programming Guide

[Contents][Index][Back][Next]

4.1.7 Locking DAM files

Suppose that, when a DAM file is being updated, an interrupt for updating the same file comes from another UAP. Two updates would then be reflected on the same logical file and would cause inconsistencies in the file. To avoid this, the function to access a file can contain a specification for locking the file. Through this lock control, data consistency can be assured on DAM files even when they are accessed from more than one UAP.

Organization of this subsection
(1) Lock modes
(2) Lock units (recoverable DAM files)
(3) Specification of waiting for a resource to be released from lock
(4) Lock in online mode and offline mode

(1) Lock modes

Lock conditions for accessing DAM files are called lock modes. The following lock modes are available:

Lock for reference (shared mode PR Protected Retrieve):
The UAP can only reference files with lock specified. Other transactions are permitted only to reference the files.

Lock for update (exclusive mode EX EXclusive):
The UAP can reference and update files with lock specified. Other transactions are not permitted to reference or update the files.

(2) Lock units (recoverable DAM files)

Lock can be specified in units of blocks or files when a DAM file is accessed in online mode as explained below.

(a) Block-based locks

Lock is enabled in blocks. When a block is referenced, the lock of the shared mode is enabled. When a block is updated or output, the lock of the exclusive mode is enabled. The specification of lock for reference can be disabled by specifying no lock in the option (other UAPs allowed to reference/update blocks). The specification of the acquired lock is reset when the transaction processing that specified processing for the DAM file terminates normally.

(b) File-based lock

Each logical file can be locked. If locking of a logical file is specified, the entire file will be locked during the period from the time the file is opened to the time the transaction process terminates normally.

File-based lock can be specified in the following condition:

File-based lock cannot be specified in the following cases. Use block-based lock.

(3) Specification of waiting for a resource to be released from lock

(4) Lock in online mode and offline mode

A DAM file being used in online mode cannot be accessed in offline mode. To access a DAM file, being used in online mode, in offline mode, use the damhold and damrm command to switch the online mode to the offline mode. Then, use the damadd command to switch the DAM file back into the online mode.

Even in offline mode, different UAPs cannot access one DAM file at the same time. The UAP process that has opened a DAM file uses it exclusively until it is closed.