Shared files

 

File management on the i5/OS® operating system provides several levels of support for shared files. Files can be shared among many users, many jobs, or many programs within the same job.

The system automatically provides the first level of support. By default, the system lets multiple users and multiple jobs use one file at the same time. The system allocates the file and its associated resources for each use of the file in such a way that it can prevent conflicting uses. Within the same job, programs can share files if one program opens the same file more than once or if different programs open the same file. Even though the same file is being used, each open operation creates a new path from the program to the data or device so that each open operation represents an independent use of the file.

 

Open data path

A closer level of sharing within a job allows more than one program to share the same path to the data or device. This path, called an open data path, is the path through which all of the read and write operations for the file are performed. You can use this level of sharing by specifying the SHARE parameter on the create file, change file, and override file commands. The SHARE parameter allows more than one program to share the file status, positions, and storage area. It can improve performance by reducing the amount of main storage the job needs and by reducing the time it takes to open and close the file. The i5/OS operating system bases this level of sharing on two models:

 

Shared files in the original program model

In the original program model, the SHARE(*YES) parameter lets two or more programs that run in the same job share an open data path (ODP). It connects the program to a file. If not specified otherwise, every time a file is opened a new open data path is built. You can specify that if a file is opened more than once and an open data path is still active for it in the same job, the active ODP for the file can be used with the current open of the file; a new open data path does not need to be created. This reduces the amount of time that is required to open the file after the first opened to open the file after the first open, and the amount of main storage that is required by the job. You must specify SHARE(*YES) for the first open and other opens of the same file to share the open data path. A well-designed (for performance) application will normally do a shared open on database files that multiple programs will open in the same job. Specifying SHARE(*YES) for other files depends on the application.

 

Shared files in the ILE model

In the ILE model, shared files are scoped either to the job level or to the activation group level. An activation group is a substructure of a runtime job. It consists of system resources (storage for program or procedure variables, commitment definitions, and open files) that are allocated to one or more programs. An activation group is like a miniature job within a job.

Any programs that run in any activation group can share shared files that are scoped to the job level. Only programs that run in the same activation group can share shared files that are scoped to the activation group level.

 

Shared files: Considerations

Sharing files allows you to have programs within a job interact in ways that would otherwise not be possible. However, understand the effects of opening, performing read and write operations, and closing shared files.

You should also see the appropriate documentation for all of the file types to understand how this support works, and the rules your programs must follow to use it correctly.

Most high-level language programs process an open or a close operation independent of whether the file is being shared. You do not specify that the file is being shared in the high-level language program. You indicate that the file is being shared in the same job through the SHARE parameter. You specify the SHARE parameter only on the CREATE, CHANGE, and OVERRIDE file commands. Refer to your appropriate language information for more information.

 

Parent topic:

Working with database files

 

Related concepts


File types
Monitoring file status with the open and I/O feedback area