COBOL Manual for TNS/E Programs (H06.08+, J06.03+)

By default, files that are audited by TMF use cache buffering, and files that are not audited do not.
CAUTION: Do not use cache buffering with a program that requires that each record actually
be written on the disk before the next statement in the program is executed. If your program is
writing to a file that is opened with the exclusion mode SHARED or PROTECTED, give careful
consideration to the use of cache buffering, because other processes can read the file and could
read a record that your writing process has updated but which the file system has not yet delivered
to the disk.
When a file is opened, the call to the FILE_OPEN_ procedure includes a parameter that determines
whether or not cache buffering is used—that is, whether the file has the attribute BUFFERED. You
can give a file the BUFFERED attribute by using FUP routines or the corresponding Enscribe routines
through environment procedure calls; then all output to the file is done with cache buffering.
Each disk has its own cache. Each cache is configured to have space for a certain quantity of disk
data. Each disk device has an associated disk process that performs the physical operations of
reading data from the disk into cache memory and writing data from cache memory to the disk.
When a process requests a record from a given disk, the Enscribe record manager checks that
particular cache for the block that contains the record. If that block is not present in the cache,
Enscribe must perform a physical read from the disk and then return the record to the application
process. If the block is present, Enscribe does not need to do the read operation; it can simply
return the record to the application process.
Sequential Block Buffering
Sequential block buffering (SBB) is an Enscribe feature that speeds the sequential reading of a
structured file by reading a block of records together into a memory buffer. Enscribe allocates the
buffer in the process file segment outside the data space of your process.
NOTE: With the advent of the DP2 disk processing system, “normal” I/O could be faster than
sequential block buffering, depending on the number of records per block. For example, a file
containing eight 4K blocks and 1600 records requires one physical I/O operation and 1600
interprocess messages in normal mode, but eight physical I/O operations and only eight interprocess
messages in SBB mode; on the other hand, a file with eight 4K blocks and only eight records
requires one physical I/O and eight interprocess messages in normal mode, but eight physical
I/O operations and eight interprocess messages in SBB mode
If the file has no alternate keys, the size of the buffer is the block size of the file. If the file has
alternate keys, the alternate-key file (not the primary file) is buffered, because the alternate-key file
is being read sequentially, while the primary file is probably being read randomly.
Without sequential block buffering, every time an application program performs a read operation,
the HP COBOL run-time routines must call the READ routine, which causes the file system to send
a message to the disk process and causes the disk process to return a message containing the
record. With sequential block buffering, only entire blocks are sent, and any records in the block
after the first one are delivered from the process file segment without any message traffic.
HP COBOL provides sequential block buffering for a file when all of these conditions are met:
The file is structured.
The file’s open mode is INPUT or I-O.
The program declares the file to have sequential access mode (although organization can be
sequential, relative, or indexed).
CAUTION: Do not use sequential block buffering for a file opened for shared access. If you do,
a process could read data that is not up to date while another process alters the file.
878 Disk Input and Output