When using BSAM with overlapped I/O (multiple I/O requests outstanding
at one time), you must use more than one DECB. Specify a different
DECB for each I/O request. For example, if you specify NCP=3 in your
DCB for the data set and you are reading records from the data set,
you can code the following macros in your program:
...
READ DECB1,...
READ DECB2,...
READ DECB3,...
CHECK DECB1
CHECK DECB2
CHECK DECB3
...
This is a more efficient technique:
READ DECB1,...
READ DECB2,...
READ DECB3,...
CHECK DECB1 Beginning of loop
READ DECB1,...
CHECK DECB2
READ DECB2,...
CHECK DECB3
READ DECB3,...
(Repeat the previous six macros until a
CHECK macro causes entry to EODAD routine.)
This is a generalized technique that supports any value for NCP:
- Supply a DCBE with a nonzero MULTSDN and a nonzero MULTACC. For
optimization you can select the MULTACC value to be half of the MULTSDN
value.
- Issue an OPEN macro. OPEN calculates an NCP value. If using LBI
to process a tape data set and the block size is greater than 32 768,
the minimum calculated NCP value is 2 and the maximum value is 16.
- Allocate storage for a number of data areas equal to the NCP value
and for an equal number of DECBs. They do not have to be contiguous.
The DECBs must be below the 16 MB line, but the data areas can be
above the 16 MB line. Central storage addresses can be above 2 GB.
After each DECB you can add a word pointing to the next DECB and point
the last one to the first DECB. This simplifies finding DECBs.
- For each DECB area, copy a single DECB to it, and issue a READ
or WRITE macro to it, supplying an appropriate data area address.
The
source of the DECB copy can be above or below the 16 MB line but the
destination must be below the 16 MB line.
- Repeat the following steps for each DECB until a CHECK macro for
a READ causes entry to the end-of-data exit (EODAD) routine or until
you have nothing more to write:
- Issue the CHECK macro (for oldest outstanding READ or WRITE)
- Process data in block if you are reading, or create a block in
data area if you are writing.
- Issue the READ or WRITE macro to the DECB.
- Load a pointer to the next DECB (to get oldest outstanding READ
or WRITE).
- If you are writing, then issue a CHECK macro for each remaining
outstanding DECB in the order of the WRITEs. If you are reading, do
not issue another CHECK.
- Issue a CLOSE macro and free storage.
Figure 3 shows this technique, except for the FIND
macro and DSORG=PO in the DCB macro. To process a sequential data
set, code DSORG=PS. You can easily adapt this technique to use WRITE
or READ.