next up previous contents index
Next: MZLINK / MZLINT Up: Memory management Previous: MZSTOR - initialize

MZDIV - create a new division

MZDIV may trigger relocation.

A dynamic store is physically subdivided into 'divisions'. Up to 20 divisions are allowed, which permits 17 divisions created by the user with MZDIV, beyond the 3 divisions created initially by MZSTOR.

Dividing the store into divisions is a device for keeping different data-structures in physically separate parts of the dynamic store. In principle the user does not need to care where and in what order his banks are kept physically in the store, since all logical relations are described by links, not by arrangement. The reason for using divisions in spite of this general principle is exclusively the possible gain in efficiency, when deleting a whole data-structure, for example, or with the output of a data-structure to tape or disk. This may be seen by comparing the operations necessary to output either a data-structure whose banks co-exist intermixed with the banks of other structures, or a data-structure which has the exclusive use of a division: the first case requires a logical walk through the data-structure to identify all the banks which belong to it, plus the construction of a table to indicate their where-abouts, and the write-out of the memory according to that table; in the second case a contiguous chunk of memory can be written out directly.

Mode of a division: depending on whether a division grows at its higher or at its lower end, a division is said to be of mode 'forward' or 'reverse' (MODE = 0 or 1). Reverse mode is selected by the R option in the call to MZDIV, else forward mode is assumed. By arranging a forward division to be followed by a reverse division (of the same kind), the 'reserve areas', ie. the reserved space for these divisions not currently allocated to banks, of the two divisions is contiguous and is hence available to either division, thereby reducing the total memory requirement in general.

Kind of a division: Depending on its usage, we distinguish three kinds of divisions (apart from the system division, which is used by the ZEBRA system itself):

Links, including structural links, may in general point from one division to any other division of the same store, except that the link 'next-of-same' may not, ie. a linear stucture must be contained within one division. To reduce the load on relocation, the user has the possibility to indicate which division points to which other divisions, as explained in section gif for MZXREF. By default ZEBRA assumes that all user divisions may point to all other user divisions.

User short-range divisions are allocated one after the other from left to right, starting with division 1; long-range and package divisions are allocated one before the other from right to left, starting with division 20, pushing the system division downwards.

A given division in a particular store is identified by its 'index'; thus if a bank is to be created in this division, its index has to be specified to MZLIFT. The division index carries the store-number and the division-number encoded onto a word of 32 bits; when a new division is created by a call to MZDIV the next free division-number is allocated to it, and the encoded division index is returned to the user as an output parameter. The store index, constructed by MZSTOR, is formally a division index for the (non-existing) division zero. The format of the division index permits the simultaneous selection of several divisions by a 'compound index', see section gif for the specifications.

A division is created with:

CALL MZDIV (IXSTOR,IXDIV*,chNAME,NW,NWMAX,chOPT)

with

      IXSTOR  index of the store for creation,
              zero for the primary store

      IXDIV*  returns the index of the division created,
              to be used when specifying this division
              in subsequent calls to the ZEBRA system.

      chNAME  name of the division for printing purposes,
              8 characters maximum

          NW  number of words to be allocated to the division initially,
              during execution later the division may grow, but not beyond
       NWMAX  maximum size of the division

       chOPT  character string of options:

             mode:      forward mode is default    (gives MODE = 0
                     R  reverse division                  MODE = 1
                     M  match the neighbour division      MODE = 0 or 1

             kind:      user short-range is default       KIND = 1
                     L  user long-range division          KIND = 2
                     P  package division                  KIND = 3 )
                        (P implies C, over-rules L)

             xref:      by default all user divisions point to all other
                                   user divisions (see section~\ref{sec:MZXREF})
                     C  division contained, ie. no links point outside

Required:     NW at least 100 words,  NWMAX at least NW words

Examples:

      CALL MZDIV (0,IXHITS,'HITS',10000,20000,'.')

           creates a user short-range division HITS in forward mode.

      CALL MZDIV (0,IXCALI,'CALIB',8000,8000,'RL')

           creates a user long-range division CALIB in reverse mode.

If the user creates several divisions it is economic to create pairs of forward/reverse divisions. With Zebra version 3.67 the mode option M has been introduced to request automatic pairing with the divisions already existing.

Example:

      CALL MZSTOR (0, '//', ...
      CALL MZDIV  (0, IXABC, 'ABC', NW3,  NWMAX3, 'M')
      CALL MZDIV  (0, IXDEF, 'DEF', NW4,  NWMAX4, 'M')
      CALL MZDIV  (0, IXXYZ, 'XYZ', NW20, NWMX20, 'LM')
      CALL MZDIV  (0, IXUVW, 'UVW', NW19, NWMX19, 'LM')

This will give a primary store with this lay-out:

   | div 1      div 2 | div 3      div 4 |   div    | div 19      div 20 |
   |                  |                  |  system  |                    |
|  | ----->    <----- | ----->    <----- |     <--  | ------>    <------ |
|__|__________________|__________________|__________|____________________|

The forward divisions 3 and 19 are followed by the reverse divisions 4 and 20. The divisions of each pair share the same memory region, originally of NW3+NW4 and NW19+NW20 words. Thus the occupied space of one division can be large (even larger than its own declared maximum) at a particular moment during execution, if the space occupied by the other division of the pair is small enough to keep the sum below the maximum.

Remember:

the higher logical entity above the bank is the 'data-structure' and not the division; the division is a physical concept entirely different from the logical concept of the data-structure, and the two must not be confused.

MZDIV prints at log level 0 or above an initialization message on unit IQLOG.



next up previous contents index
Next: MZLINK / MZLINT Up: Memory management Previous: MZSTOR - initialize


Janne Saarela
Mon May 15 08:34:47 METDST 1995