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

You can divide an indexed file according to the value of the prime key and have, for example, A
through C on the first disk volume and U through Z on the last disk volume. If one of the disks is
taken offline for maintenance, or if one system of the network is inaccessible due to communication
problems, the remainder of the partitioned file is still accessible.
To open a partitioned file when some partitions cannot be accessed, an HP COBOL program must
use the routine COBOL_SPECIAL_OPEN_. If all partitions can be accessed, an HP COBOL program
can open a partitioned file with the OPEN statement.
For more information about partitioned files, see Partitioned Files.
Optimizing Disk File Storage
You can specify at file creation time that an indexed or data file is to be compressed for more
space-efficient storage at a slight expense of speed. Enscribe compresses records by eliminating
duplicate leading characters from one record to the next and replacing them with a one-byte count
of the duplicate characters. If a file has a significant amount of duplicated data, the storage saving
can be substantial.
The prime key of a compressed file must be at the beginning of the record.
Compression is recommended for an indexed file in which the first records of successive blocks
have similar prime-key values. Compression is recommended for an alternate-key file in which
several alternate keys have the same value.
For more information about compressing indexed and data files, see the Guardian Programmer’s
Guide.
Avoiding Deadlock
Deadlock is a situation in which two processes are in contention for a single-user resource. If both
processes require exclusive use of both resources, they are deadlocked. Neither can proceed until
the other surrenders control of the resource it has under its control. If two servers get into a deadlock,
their respective requesters are also deadlocked because neither requester receives a reply from its
server.
One example of deadlock is when one process has opened a file (call it ABLE) and needs to open
another file (call it BAKER), while another process has opened BAKER and now needs to open
ABLE.
Another example of deadlock is when one process has locked a record in a file (call it record n )
and wants to read another record in the file (call it record m ), while some other process has locked
record m and wants to read record n.
The ways to avoid deadlock are:
Locking and Unlocking Files and Records
Setting Time Limits on Input-Output Operations
Locking and Unlocking Files and Records
The most complete way for a process to lock a file is to open the file for exclusive access (open it
with the exclusion mode EXCLUSIVE). This strategy prevents all other processes from reading or
writing the file.
If it is not feasible for one process to have exclusive control of a file for when it has the file open,
there are alternatives.
One alternative is protected access. When a process opens a file for protected access (opens it
with the exclusion mode PROTECTED), other processes can read and write the file while the opening
process has it open, but cannot write the file until the opening process closes the file.
Optimizing Disk File Storage 881