|
To maintain write integrity for the data set, your program must
ensure that there is no conflicting activity against the data set
until your program completes updating the control interval. Conflicting
activity can be divided into two categories:
- A data set that is totally preformatted and the only write activity
is update-in-place.
In this case, the sharing problem is simplified
by the fact that data cannot change its position in the data set.
The lock that must be held for any write operation (GET/PUT RPL
OPTCD=UPD) is the unit of transfer that is the control interval.
It is your responsibility to associate a lock with this unit of transfer;
the record key is not sufficient unless only a single logical record
resides in a control interval.
The following is an example of
the required procedures:
- Issue a GET for the RPL that has the parameters OPTCD=(SYN,KEY,UPD,DIR),ARG=MYKEY.
- Determine
the RBA of the control interval (RELCI) where the record
resides. This is based on the RBA field supplied in the RPL. For extended-addressible
data sets, this would be the lower six bytes of the field RPLRBAR;
for non-extended-addressable data sets, it would beRPLDDDD.
RELCI=CISIZE * integer-part-of (RPLDDDD / CISIZE)
- Enqueue MYDATA.DSNAME.RELCI (the calculated value).
- Issue an ENDREQ.
- Issue a GET for the RPL that has the parameters OPTCD=(SYN,KEY,UPD,DIR),ARG=MYKEY.
This action will do I/O and get a refreshed copy of the buffer.
- Determine
the RBA of the control interval (RELCI) where the record
resides. This is based on the RBA field supplied in the RPL. For extended-addressable
data sets, this would be the lower six bytes of the field RPLRBAR;
for non-extended-addressable data sets, it would beRPLDDDD.
.
RELCI = CISIZE * integer-part-of (RPLDDDD / CISIZE)
Compare
the calculated values. If they are equal, you are assured the control
interval has not moved. If they are not equal, dequeue resource from
step "c" and start over at step "a".
- Issue a PUT for the RPL that has the parameters OPTCD=(SYN,KEY,DIR,UPD).
This does not hold position in the buffer. You can do one of the following:
- Issue a GET for the RPL that has the parameters OPTCD=(SYN,KEY,UPD,DIR),ARG=MYKEY.
This will acquire position of the buffer.
- Issue a PUT for the RPL that has the parameters OPTCD=(SYN,KEY,DIR,NSP).
This does hold position in the buffer.
- Issue an ENDREQ. This forces I/O to DASD, will drop the position,
and cause data buffer invalidation.
- Dequeue MYDATA.DSNAME.RELCI.
- A data set in which record additions and updates with length changes
are permitted.
In this
case, the minimum locking unit is a control area to accommodate control
interval splits. A higher level lock must be held during operations
involving a control area split. The split activity must be serialized
at a data set level. To perform a multilevel locking procedure, you
must be prepared to use the information provided during VSAM JRNAD
processing in your program. This user exit is responsible for determining
the level of data movement and obtaining the appropriate locks.
Higher
concurrency can be achieved by a hierarchy of locks. Based on the
particular condition, one or more of the locking hierarchies must
be obtained.
Lock |
Condition |
---|
Control Interval |
Updating
a record in place or adding a record to a control interval without
causing a split. |
Control Area |
Adding
a record or updating a record with a length change, causing a control
interval split, but not a control area split. |
Data Set |
Adding
a record or updating a record with a length change, causing a control
area split. |
The following is a basic procedure to provide the necessary
protection. Note that, with this procedure, all updates are locked
at the at the data set level:
SHAREOPTION = (4 3) CBUF processing
Enqueue MYDATA.DSNAME Shared for read only;
exclusive for write
Issue VSAM request macros
...
Dequeue MYDATA.DSNAME
In any sharing situation, it
is a general rule that all resources be obtained and released between
the locking protocol. All positioning must be released by using all
direct requests or by issuing the ENDREQ macro before ending the procedure
with the DEQ.
|