Newsgroups: comp.sys.acorn.tech
Subject: Of the RMA and it's terminal weirdness.
From: banksie@khantazi.welly.gen.nz (Philip R. Banks)
Date: Sun, 13 Sep 1992 02:09:42 +1200
Reply-To: banks_p@kosmos.wcc.govt.nz
Organization: My Arc.

   Could someone at Acorn please post to the net an explanation of the RMA's
memory allocation system before I lynch my RO2 ROMs! I am getting behavior
that is *very* odd and I'd like to know why it is occuring. To explain :-

I have coded a little module, DataStart, that uses my other DataSuite
modules to handle playing a sample once and then removing it from memory
(for startup sounds essentially). Because I want to let the machine keep
booting whilst it is playing the sound I am holding the sample in the RMA
during play.

   Now I want to prevent this sample block from being trapped in the RMA.
So, thought I, if I write the code to claim a largish block of memory before
claiming the RMA block for the sample and then freeing that block after
loading the sample I should give the RMA sufficient free room *below* the
sample to prevent it putting blocks above the sample block.

   Unfortunately it seems the RMA does not think in such a simplistic way.
Even telling the code to claim 'free' spaces of 900K does not help even
though the rest of my boot sequence only needs 256K of RMA memory extra. For
some reason blocks get allocated *above* the sample thereby locking it's
space into the RMA.

   Now to this behavior add the odd behavior an Extend Block OS_Module call
exhibits when the extension size is zero bytes. You see for various reasons
some code I am working on will be extending and shrinking RMA blocks a fair
amount and I would like to force the RMA to locate these blocks as low as
possible freeing up as much RMA ap is possible. Now I would have thought
telling the RMA to extend the block by zero bytes would cause it to relocate
the block, possibly lower. (and there would be certain circumstances when I
would *know* that there was sufficient RMA free down lower in the RMA to do
this.)

   Yet what appears to happen is that the RMA relocates the block *up*
higher while *not* freeing the space the block originally occupied. Net
result everytime you try the extension by zero trick more RMA gets trapped -
marked as in use. Yet when the block is released the whole lot gets released
in one go!?!

   All this seems to indicate that the RMA has some unusual memory
allocation scheme almost like a 'binary buddies' system where the pattern of
allocation/deallocation is not in a linear fashion from the bottom up. Could
*somebody* please explain what this scheme is and what might be 'legal' ways
to try and massage the RMA into behaving more sensibly?

   Post, email & courier snail will do nicely, preferrably posted if it is a
definitive answer as I suspect other people would like to know what the RMA
Manager is doing...

    Philip

--
Philip R. Banks  Syntax: mail < banks_p@kosmos.wcc.govt.nz >            @@@@@/|
Take a look around you at the world we've come to know,                 @@@@/#|
Does it seem much more than a crazy circus show?                        @@@/##|
Maybe from the madness something beautiful will grow....                @@/---|
   ---The Artilleryman from Jeff Wayne's "War of the Worlds"            @/    |