next up previous contents index
Next: MZLIFT / MZBOOK Up: Memory management Previous: MZLINK / MZLINT

MZWORK - allocate working space

 

MZWORK may wipe division 1 and it may trigger garbage collection.

The region at the beginning of the dynamic store just after the permanent links may be used as working space, consisting of a set of reference links followed by a set of data words.

The user requests reservation of the working space with

CALL MZWORK (IXSTOR,DFIRST,DLAST,IFLAG)

with  IXSTOR  index of the store or of any of its divisions,
              zero for the primary store

      DFIRST  first data word of the working space,
              the preceding words are taken as reference links;
              this parameter is ignored if IFLAG is =2 or =-1

       DLAST  last data word,
              this parameter is ignored if IFLAG is =-1 or =3 or =4

       IFLAG  = 0  define a new working space,
                   previous contents are not to be retained

              = 1  vary the limits of the working space,
                   keeping intact the links which are common to
                   both the old and the new working space.

              = 2  vary only the DLAST limit of the working space,
                   keeping alive all links and the data words
                   which are common to the old and the new working space.

              = 3  keep the DLAST limit unchanged, keep division 1,
                   re-define the DFIRST limit for new links,    
                   ie. clear the links to zero.             

              = 4  keep the DLAST limit unchanged, keep division 1,
                   re-define the DFIRST limit keeping intact the links
                   which are common to the old and the new working space.

              =-1  reset the working space to null,
                   ie. to zero links, zero data words
Staring with Zebra version 3.67, the links of the working space are cleared to zero by
MZWORK; if IFLAG = 1 or 4 only the new links are cleared.

A call to MZWORK with IFLAG < 3 destroys division 1 of the store without a relocation pass to reset links pointing into division 1. This is done in this way for efficiency, hence normally only very temporary data should be kept in division 1, and only working space links should point to them. To say it differently: division 1 is logically part of the working space, its time of existence is the same as that of the working space, and it is good practice to maintain links into division 1 only in the working space. If however it is necessary to hold such links elsewhere, one should either reset them explicitly or wipe the division with CALL \Rind{MZWIPE(1)} before calling MZWORK [ or with CALL \Rind{MZWIPE(IXSTOR+1)} for a secondary store ].

Example:

+CDE, Q.
     +,         LR1, ...     working space reference links
     +,         DFIRST, ...  working space data words
     +,         DLAST

      CALL MZWORK (0,DFIRST,DLAST,0)

will give this layout of the store:

    _____________________________________________________________
   |           |       |             |               |           |
   | permanent |  wsp  |   w. space  | div 1   div 2 | other     |
   |   links   | links |     data    | --->     <--- | divisions |
   |___________|_______|_____________|_______________|___________|
   |LQ         |LR1    |DFIRST  DLAST|                           |

MZWORK prints a monitor log message at level 2.


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