You can use the callable cell pool services to manage the virtual
storage of a data space. Callable cell pool services allow you to
divide data space storage into areas (cells) of the size you choose.
Specifically, you can
- Create cell pools within a data space
- Expand a cell pool, or make it smaller
- Make the cells available for use by your program or by other programs
A cell pool consists of three different areas:
- One anchor
- Up to 65,000 extents
- Cells, all of which are the same size
The anchor and the extents allow callable cell pool services to
keep track of the cell pool.
This section gives an example of one way a program would use the
callable cell pool services. This example has only one cell pool
with one extent. In the example, you will see that the program has
to reserve storage for the anchor and the extent and get their addresses.
For more information on how to use the services and an example
that includes assembler instructions, see the section on callable
cell pool services in z/OS MVS Programming: Assembler Services Guide.
Example of Using Callable Cell Pool Services
with a Data Space
Assume that you have an application that requires up to 4,000 records
that are each 512 bytes in length. You have decided that a data space
is the best place to hold this data. Callable cell pool services
can help you build a cell pool, each cell having a size of 512 bytes.
The steps are as follows:
- Create a data space (DSPSERV CREATE macro)
Specify a size large
enough to hold 2,048,000 bytes of data (4000 times 512) plus the data
structures that callable cell pool services need.
- Add the data space to an access list (ALESERV macro)
The choice
of DU-AL or PASN-AL depends on how you plan to share the data space.
- Reserve storage for the anchor and obtain its address
The anchor
(of 64 bytes) can be in the address space or the data space. In this
example, the anchor is in the data space.
- Initialize the anchor (CSRPBLD service) for the cell pool
Input
to CSRPBLD includes the ALET of the data space, the address of the
anchor, the name you assign to the pool, and the size of each cell
(in this case, 512 bytes). Because the anchor is in the data space,
the caller must be in AR mode.
- Reserve storage for the extent and obtain the address of the extent
The
size of the extent is 128 bytes plus one byte for every eight cells.
In this example, adding 128 to 500 (that is, 4000 divided by 8) equals
628 bytes. The system then rounds up to a doubleword making the extent
632 bytes.
- Obtain the address of the beginning of the cell storage
Add
the size of the anchor (64 bytes) and the size of the extent (632)
to get the location where the cell storage can start. You might want
to make this starting address on a given boundary, such as a doubleword
or page.
- Add an extent for the cell pool and establish a connection between
the extent and the cells (CSRPEXP service)
Input to CSRPEXP includes
the ALET for the data space, the address of the anchor, the address
of the extent, the size of the extent (in this case, 632 bytes), and
the starting address of the cell storage. Because the extent is in
the data space, the caller must be in AR mode.
At this point, the cell pool structures are in place and users
can begin to request cells. Figure 1 describes the areas
you have defined in the data space.
Figure 1. Example of Using Callable Cell Pool Services for Data Spaces
A program that has addressability to the data space can then obtain
a cell (or cells) through the CSRPGET service. Input to CSRPGET includes
the ALET of the space and the address of the anchor. CSRPGET returns
the address of the cell (or cells) it allocates.
Programming Notes for the Example
- The origin of the data space might not be zero for the processor
the program is running on. To allow the program to run on more than
one processor, use an origin of 4K bytes or use the ORIGIN parameter
on DSPSERV to obtain the address of the origin.
- If you need more than one extent, you might have a field that
contains the ending address of the last cell pool storage. A program
then could use that address to set up another extent and more cells.
- To use callable cell pool services, the caller must be executing
in a state or mode or key in which it can write to the storage containing
the anchor and the extent data areas.
- The anchor and the extents must be in the same address space or
data space. The cells can be in another space.