home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 5
/
DATAFILE_PDCD5.iso
/
utilities
/
d
/
dynamite
/
DynManText
< prev
next >
Wrap
Text File
|
1995-08-01
|
31KB
|
1,145 lines
_
/ \ ___ ___ _____ · /_ __
/ ) / / / ) / ) / / ) / / /__)
/___/ (___/ / ( (___( / / ( (_ (_ (___
____/
Programmer's Guide
Straylight
16 Portland Street, Royal Leamington Spa,
Warwickshire, CV32 5HE
Telephone and facsimile: 01926 452639
Email: strylght@strylght.demon.co.uk
_____________________________________________________________________________
© 1995 Straylight
This documentation refers to Dynamite module version 1.15
The Dynamite software and accompanying documentation are to be
considered as `Freeware' -- they may be reproduced and distributed on
condition that they are not altered in any way and no profit is made
by so doing. You may supply the Dynamite module with any software
which uses it, including software for which a profit is made.
Because the program is licensed free of charge, there is no warranty
for the program, to the extent permitted by applicable law. Except
when otherwise stated in writing the copyright holders and/or other
parties provide the program `as is' without warranty of any kind,
either expressed or implied, including, but not limited to, the
implied warranties of merchantability and fitness for a particular
purpose. The entire risk as to the quality and performance of the
program is with you. Should the program prove defective, you assume
the cost of all necessary servicing, repair or correction.
The product described in this documentation is the subject of
continual development and, while all efforts are taken to ensure
that the information given is correct, Straylight cannot accept any
liability for loss or damage resulting from the use or misuse of this
product.
Trademarks
Acorn, Archimedes and RISC PC are trademarks of Acorn Computers Ltd.
ARM is a trademark of Advanced RISC Machines Ltd.
All other trademarks acknowledged.
_____________________________________________________________________________
Dynamite overview
What does Dynamite do?
One of the greatest problems facing module writers is that of
allocating memory. Although the Relocatable Module Area has been
provided to allow modules to allocate workspace, its design causes
it to fragment over a period of time.
Programmers have been aware of this problem for a long time, and
several have started to use the System Sprite Area as an alternative
source of memory, since it does not suffer from fragmentation in the
same way as the RMA.
Acorn have finally addressed this difficulty and enabled modules
running under RISC OS 3.5 or later to create their own dynamic areas,
which they can then manage themselves, for example, by implementing a
shifting heap similar to that used by most applications.
Unfortunately this solution is not available to programs required to
run on machines earlier than the RISC PC.
Dynamite is a small module which provides a solution to the problem
of memory allocation without causing fragmentation of the RMA,
abusing the Sprite area, or being specific to any particular
operating system versions. This means that code which uses Dynamite
should be able to run on any version of RISC OS.
Running under RISC OS 3.5 or later, Dynamite creates its own dynamic
area and implements within it a shifting heap which is compacted over
a period of time by a WIMP task.
Under earlier versions of RISC OS, Dynamite shuffles the memory map
to create its own `dynamic area', and implements within it a
shifting heap as before.
The interface to the Dynamite memory manager is identical, whether or
not a real dynamic area is used. Since blocks are always allocated
within Dynamite's special area of memory, clients which require
blocks of memory and can cope with them being moved around can now
obtain them without fragmenting the RMA.
How Dynamite works
Operation under RISC OS 3.5 or later
Dynamite's operation under RISC OS 3.5 is fairly simple -- the new
facilities provided by OS_DynamicArea are used to create and resize
the heap as required.
Operation under RISC OS versions prior to 3.5
Since early versions of RISC OS do not provide calls for creating
dynamic areas, Dynamite takes matters into its own hands. It uses
the area of logical memory at the end of the System Sprite area (up
to &01800000) to build its heap.
Normally, the System Sprite Area is layed out as shown below:
[Picture: DynManDocs.Diag_1/1]
Only the shaded area used by the system sprites actually has physical
memory pages associated with it.
Dynamite creates its area at the other end of the System Sprite Area,
from 24M downwards, as shown overleaf.
[Picture: DynManDocs.Diag_1/2]
Operating system routines are intercepted to ensure that Dynamite's
maintenance of this area does not affect the normal operation of the
kernel's memory management.
It should be noted that because of this method of implementation,
there is a limit of 4M (assuming there are no System Sprites) on the
size of Dynamite's heap. The RMA also has a limit of 4M, and this
is rarely exceeded, so this is unlikely to cause a problem in
practice.
It should be noted that the Task Manager will show the size of the
Sprite area including Dynamite's area. However, OS_ReadDynamicArea
will return only the amount occupied by the System Sprites, allowing
programs which use sprites to store their data to work as before.
OS_ChangeDynamicArea will continue to work as before; only the area
containing the System Sprites will change in size.
Warning: To the best of our knowledge, there are no other programs
which use the area of memory at the end of the Sprite area. If
similar modules appear, there are likely to be severe compatibility
problems. It is for this reason that we have decided to publish the
interface to Dynamite.
_____________________________________________________________________________
Using Dynamite
Who can use Dynamite?
Straylight have decided to make this module `freeware'. It remains
at all times Copyright © 1994 Straylight, however it may be
distributed with products which wish to use it, whether or not they
are commercial. No charge may be made for Dynamite specifically,
and the module must not be altered in any way.
All products distributed with Dynamite must state in the main
documentation that Dynamite is © 1994 Straylight.
Loading Dynamite
Dynamite should normally be loaded from an Obey file in the following
way:
RMEnsure Dynamite 0.00 RMRun <My$Dir>.Dynamite
RMEnsure Dynamite 1.11 Error 0 Dynamite module is too old
It is important to note that the Dynamite module must be RMRun, not
just RMLoaded -- this will ensure that the Dynamite WIMP task is
started correctly.
_____________________________________________________________________________
About the Dynamite heap
Shifting heaps
Dynamite allocates blocks from a shifting heap. This means that
blocks allocated from the heap will be moved around in order to
close up any gaps created by freeing blocks. In a normal heap, for
example that implemented by OS_Heap or the C library's malloc
function, the free memory in the heap can become fragmented