next up previous contents index
Next: MZDROP - drop Up: Memory management Previous: MZPUSH - alter

MZREPL - connect replacement banks

If one wants to replace a given 'old' bank in a data-structure by a 'new' bank, and if there are links elsewhere in the data-structure(s) or in link-areas pointing to the old bank, this is a non-trivial operation because these links have to be relocated to point to the new bank. Normally this can be done with MZPUSH, but not if the I/O descriptor has to change. For these cases MZREPL is provided.

The user is supposed to lift and fill the 'new' bank and also a tiny 'index' bank with 2 (structural) links and 1 data word, recording the address of the old bank in link 1 and the address of the new bank in link 2. This index bank is handed to MZREPL which will then execute the necessary relocation, using the data word as working storage.

If several such operations are needed one should not loop over calls to MZREPL, but construct a linear structure of index banks for MZREPL, which will then do all the replacements with one single relocation pass. Because of this feature MZREPL can be more economical than MZPUSH for multiple replacements.

Both the old and the new banks are required to be in one single division, but the index banks may be in a different division.

CALL MZREPL (IXDIV, *!LIX*, chOPT)

with

       IXDIV  index of the division; zero [or IXSTOR] allowed,
              in which case MZREPL will find the division

      *!LIX*  the address of the linear structure of the index banks.

       chOPT  character string of options:

                 default: drop the old and the index banks

              K  keep the old and the index banks

              I  isolated, as for MZPUSH

If one needs to keep the old banks beyond the call to MZREPL, note this: really all links pointing to the 'old' banks are relocated, and therefore one would loose access to the old banks. To overcome this the K option selects a special processing: before going into the relocation the link pointing to the old bank is saved into the data-word of the index bank (this works because there is no garbage collection involved); just before returning to the user all index banks are changed to have only 1 structural link restored to support the old bank, and link 2 continues to point to the corresponding new bank, but now as a reference link.

Each old bank is changed to have zero structural links, the 'next' link is reset to zero, and the bank is made to depend from its index bank.

When one has finished with the old banks one can drop the structure of index banks, thereby also dropping the old banks.

The linear structure of index banks is re-ordered by MZREPL for increasing address of the old banks; LIX returns the address of the new first bank.

Example:

   Replace all the banks of a linear structure.

   LIX, LOLD, LNEW  are temporary links,
   either in the working space or in a link area.

   IXDIVA is the division index of the banks;
   IXDIVX is the index of some short range division to hold the
          index banks, division 1 by preference.

      LIX = 0    clear LIX to start (reference link allowed)

      LOLD = get the adr of the first old bank

   24 CALL MZBOOK (IXDIVX, L, LIX,1, 'IXIX',2,2,1,0, -1)
      LQ(LIX-1) = LOLD

      CALL MZLIFT (IXDIVA, LNEW, LIX,-2, ...

          fill the new bank at LNEW
               ie. links LQ(LNEW-NL) to LQ(LNEW-1)
                    data IQ(LNEW+1)  to IQ(LNEW+ND)
               but not 'next', 'up', 'origin'

      LOLD = LQ(LOLD)
      IF (LOLD.NE.0)         GO TO 24

      CALL MZREPL (IXDIVA, LIX, '.')

MZREPL prints a monitor log message at level 2.



next up previous contents index
Next: MZDROP - drop Up: Memory management Previous: MZPUSH - alter


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