OpenTP1 Version 7 Programming Guide
TP1/FS/Table Access 05-00 or earlier locks the appropriate individual tables when it adds or deletes records. This facility is referred to as the TAM table access facility with table-based lock. For information about the locking of individual tables, see 4.2.6 Lock for TAM tables.
TP1/FS/Table Access 05-01 or later allows access to TAM table records while locking the appropriate records without locking entire tables. This facility is referred to as the TAM table access facility without table-based lock.
To use the TAM table access facility without table-based lock, specify the update type that allows addition and deletion without locking tables in the TAM table access mode. The access mode must be specified in the tamtable command definition clause for the TAM service definition or the tamadd command. For information about the tamtable command definition clause, see the manual OpenTP1 System Definition. For information about the tamadd command, see the manual OpenTP1 Operation.
The same OpenTP1 system can include both TAM tables that are accessed using the TAM table access facility without table-based lock and TAM tables that are accessed using the TAM table access facility with table-based lock.
You do not need to recreate existing TAM files using the tamcre command before using the TAM table access facility without table-based lock.
The dc_tam_open function and record access functions (dc_tam_read, dc_tam_write, and dc_tam_delete) lock resources. Similarly, UAPs written in COBOL and used to access records also lock resources.
Resources that have been locked are unlocked when the TAM table access transaction ends.
The table below indicates the actual lock status, as compared to the lock setting of the TAM service function used to activate the TAM table access facility without table-based lock.
Table 4-10 Actual lock status, as compared to the lock setting of the TAM service function used to activate the TAM table access facility without table-based lock
Value assigned to the TAM service function and flag | Table-based lock | Record-based lock | ||
---|---|---|---|---|
dc_tam_open | Table-based lock | Update lock#1 | -- | |
Record-based lock | -- | -- | ||
dc_tam_read | Reference | No lock | -- | -- |
Lock applied | -- | Reference lock | ||
Updating | -- | Update lock | ||
dc_tam_rewrite | -- | Update lock#2 | ||
dc_tam_write | -- | Update lock | ||
dc_tam_delete | -- | Update lock |
The figure below shows processing that is used to lock resources when updating records using the TAM table access facility with table-based lock and the TAM table access facility without table-based lock.
Figure 4-8 Locking resources when updating records
The figure below shows processing that is used to lock resources when adding records using the TAM table access facility with table-based lock and the TAM table access facility without table-based lock.
Figure 4-9 Locking resources when adding records
As explained above, the TAM table access facility with table-based lock and the TAM table access facility without table-based lock are different in the way they lock resources. For this reason, they are also different in the operation they will perform when two or more transactions compete for access to the same TAM table. If another transaction that is adding or deleting a record in the same table exists, the TAM table access facility with table-based lock cannot access the table to update, add, delete or reference the target record (if the table is locked by the function in the other transaction). The TAM table access facility without table-based lock can access the same TAM table if it does not compete with the facility in the other transaction for the record being accessed.
The figure below shows processing that is performed by the TAM table access facility with table-based lock when competition for access to the same record occurs.
Figure 4-10 Processing that is performed by the TAM table access facility with table-based lock when competition for access to the same record occurs
The figure below shows processing that is performed by the TAM table access facility without table-based lock when competition for access to the same record occurs.
Figure 4-11 Processing that is performed by the TAM table access facility without table-based lock when competition for access to the same record occurs
Note the following when using the TAM table access facility without table-based lock.
When the dc_tam_open function is issued with table-based lock specified (DCTAM_TBL_EXCLUSIVE flags is set to), it locks the table. However, it does not lock records that are included in the locked table and which may be accessed by record-access functions (dc_tam_read, dc_tam_write, and dc_tam_delete). This means that, once a dc_tam_open function that locks a table is issued, another dc_tam_open function that locks the same table must wait until the first function ends, but the record-access function does not need to wait.
The figure below shows how the dc_tam_open function locks resources.
Figure 4-12 How the dc_tam_open function locks resources
When a record is deleted, the record will not become empty until the transaction that has deleted the record is committed. This means that until the transaction is committed, the area reserved for the deleted record will not be allocated to records being added. However, when a record with the same key value as that of the deleted record is to be added within the same transaction that has deleted the record, the area for the deleted record is allocated for the record to be added.
Suppose that, in attempt to add records (even though there is not an equal number of empty records) you delete records with different key values within the same transaction that will add records. When you attempt to add records, you will encounter a DCTAMER_NOAREA error return.
The figure below shows how an attempt to add records causes a DCTAMER_NOAREA error.
Figure 4-13 An example of a DCTAMER_NOAREA error caused by an attempt to add records
To prevent an attempt to add records from causing a DCTAMER_NOAREA error, you need to obtain a number of empty records equal to the number of records you want to add or wait until the transaction that deletes records is committed, and then add records.
The figure below shows processing that is performed to obtain a number of empty records equal to the number of records to be added.
Figure 4-14 Processing that is performed to obtain a number of empty records equal to the number of records to be added
The figure below shows processing that is performed to add records after the record deletion transaction is committed.
Figure 4-15 Processing that is performed to add records after the record deletion transaction is committed
You cannot use the tamadd command to change a TAM table that uses the TAM table access facility with table-based lock to a TAM table that uses the TAM table access facility without table-based lock or vice versa. If you attempt to use the tamadd command in order to make such a change, the tamadd command ends abnormally.
If you want to switch the TAM table access facility with or without table-based lock to the other facility, change the tamtable command definition clause in the TAM service definition, and then start the OpenTP1 system as usual. Alternatively, start the OpenTP1 system, with no additional definition registered in the TAM service definition, and then use the tamadd command to add a new definition in the TAM service definition.
A deadlock can occur when a TAM table using the TAM table access facility with table-based lock is changed to a TAM table that uses the TAM table access facility without table-based lock. For further information, see (1) (b) in 4.2.11 Notes on adding and deleting TAM records.
Except for the dc_tam_status function and CBLDCTAM('INFO'), TAM tables can be accessed via the same programming interface as for the TAM table access facility with table-based lock.
However, it may be necessary to recompile or relink UAPs. Table 4-11 lists conditions that require program recompilation. Table 4-12 lists conditions that require program relinkage.
Table 4-11 Conditions that require program recompilation
Condition | Work required | |||
---|---|---|---|---|
dc_tam_status used | Yes | st_acs_type referenced | Yes | A new constant DCTAM_STS_RECLCK is returned as access mode information. Therefore, you need to modify and recompile your UAPs. |
No | You do not need to recompile your UAPs. | |||
No | You do not need to recompile your UAPs. |
Table 4-12 Conditions that require program relinkage
Condition | Work required | |
---|---|---|
Libraries used by application programs | Archive libraries | You need to relink your UAPs |
Shared libraries | You do not need to relink your UAPs. |
The dc_tam_status function returns access mode information to st_acs_type in the DC_TAMSTAT structure. Add DCTAM_STS_RECLCK as a value to be returned to st_acs_type. This value indicates an access mode in which records can be added or deleted without locking the table. A TAM table in this access mode uses the TAM table access facility without table-based lock.
For further information about the dc_tam_status function, its return values, and its usage, see the manual OpenTP1 Programming Reference C Language.
CBLDCTAM('INFO') returns access mode information to data name K. Add VALUE 'L' as a value to be returned to data name K. This value indicates an access mode in which records can be added or deleted without locking the table. A TAM table in this access mode uses the TAM table access facility without table-based lock. For further information about CBLDCTAM('INFO'), its return values, and its usage, see the manual OpenTP1 Programming Reference COBOL Language.
In the tamtable command expression of the TAM service definition, the access type can be set using the -a option. When using the access facility for TAM tables without table-based locking, be sure to specify reclck as the -a option parameter. By setting this parameter to reclck, the "non-locking add/delete update type" access format is shown, which means that the TAM table is using the access facility for TAM tables without table-based locking.
For more detail on how to use other options of the tamtable command expression, see the manual OpenTP1 System Definition.
All Rights Reserved. Copyright (C) 2006, 2010, Hitachi, Ltd.