Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
16 <strong>File</strong> <strong>Management</strong> V4R5<br />
<strong>File</strong> resource allocation<br />
When a high-level language program uses a file, several operations require that the<br />
system allocate the resources that are needed to perform that operation. The<br />
system generally does this to ensure that multiple users do not use the file in<br />
conflicting ways.<br />
For example, the system will not allow you to delete a file while any application<br />
program is using it. The system does this by obtaining a lock on the file when it<br />
opens. The delete file operation also attempts to get a lock on the file and is<br />
unsuccessful because the program using the file still has the lock from when the<br />
file was opened, and the locks conflict.<br />
<strong>File</strong> resources that must be allocated<br />
The file resources that the system must allocate depend on the type of file and the<br />
operation. <strong>File</strong> resources consist of the following:<br />
v Open<br />
– For printer and diskette files that are spooled (SPOOL(*YES)), the file<br />
resources include the file description, the specified output queue, and storage<br />
in the system for the spooled data. Because the data is spooled, the device<br />
need not be available.<br />
– For database files, the file resources consist of the entire file; this includes the<br />
file, member, data, and the associated access path.<br />
– For printer and diskette files that are not spooled (SPOOL(*NO)) as well as<br />
for tape files, display files, and some ICF files, the file resources include the<br />
file description and the device. For ICF files that use APPC, APPN, or<br />
intrasystem communications, the file resources include the file description<br />
and the session resources that are associated with the device.<br />
– For save files, the file resources consist of the entire file, including the file and<br />
data.<br />
– For DDM files, the file resources include the file description and the session<br />
resources that are associated with the device.<br />
v Acquire operation<br />
For display files and ICF files that do not use APPC/APPN or intrasystem<br />
communications, the system allocates the device as a resource. For ICF files that<br />
use APPC/APPN or intrasystem communications, resources include the session<br />
resources that are associated with the device.<br />
v Starting a program on a remote system<br />
Session resources that are needed for APPC and APPN.<br />
How the system allocates resources<br />
When it allocates resources, the system waits for a predefined time if the resources<br />
are not immediately available. If the resources do not become available within the<br />
time limit, the system generates an error. If you are using the ALCOBJ command,<br />
the command fails. If your program is performing a file operation, that operation<br />
fails, and the system sends an error message to the program message queue. You<br />
may attempt to use the error handling functions of your high-level language to try<br />
the operation again. For example, if an open operation fails because another job is<br />
using the device associated with the file, you could retry the open operation a