COBOL Manual for TNS and TNS/R Programs

Disk Input and Output
HP COBOL Manual for TNS and TNS/R Programs522555-006
28-7
Time Limits
The exclusion mode can be specified in the OPEN statement or in an ASSIGN
command. The exclusion mode in an OPEN statement takes precedence over the
exclusion mode in an ASSIGN command. If neither the OPEN statement or ASSIGN
command specifies an exclusion mode, the exclusion mode is PROTECTED if the file
is being opened for input; EXCLUSIVE otherwise.
Most server files have the exclusion mode SHARED so that several servers of the
same class can all access the file. The servers use record locking to prevent conflicting
write operations to the file.
If you have a batch program that needs to open a file that one or more servers have
opened for shared access, give careful consideration to whether the batch program
should open the file for shared, protected, or exclusive access. If the batch program is
doing something that affects the servers, it should probably open the file for exclusive
access and thus fail if any server has it open. If the batch program cannot affect the
servers, and the activity of the servers does not affect the activity of the batch program,
then the batch program can open the file for shared access.
Time Limits
If you include a TIME LIMITS phrase in an OPEN statement, you can then include a
TIME LIMIT phrase in a LOCKFILE, READ, or START statement to cause the
statement to be abandoned if it does not finish executing in a certain amount of time.
The TIME LIMIT phrase in a LOCKFILE, READ, or START statement sets the file’s
status code so that the requester can tell that the data is not currently accessible. This
action helps avoid deadlock.
Reading Files From Called Programs
Two separately compiled programs cannot share files; that is, if one program opens the
file and then calls another separately compiled program, the caller cannot pass the file
(or access to the file) to the called program. A pair of separately compiled calling and
called programs can both have the same disk file open, but each has its own record
area, its own current record pointer, its own file status data item, and so on.
Table 28-2. Exclusion Modes and Their Meanings
Exclusion Mode While the process that opened the file has it open ...
EXCLUSIVE No other process can read or write the file.
PROTECTED Any other process can read the file, but no other process can write the
file.
SHARED Any other process can read or write the file.