COBOL Manual for TNS and TNS/R Programs

Disk Input and Output
HP COBOL Manual for TNS and TNS/R Programs522555-006
28-33
Structured Files
By default, files that are audited by TMF use cache buffering, and files that are not
audited do not.
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.
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.
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.
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