AMX Memory Manager
K
A
DAK
rev9 125
10. AMX Memory Manager10.1 Introduction
The AMX Memory Manager simplifies the management of memory in an AMX system.
It provides a general mechanism for the dynamic allocation and control of memory and is
specifically designed for use in a multitasking environment.
Multitasking adds particular difficulties to the general problem of memory allocation.
For example, high level language memory management procedures, such as C's malloc,
calloc or free, cannot be called from concurrently executing tasks since the procedures
are usually not reentrant.
The Memory Manager resolves these difficulties. The Memory Manager's general
allocation procedures allow concurrently executing tasks to allocate and free blocks of
memory.
The Memory Manager allocates memory from a memory pool containing a set of one or
more sections of contiguous memory. Memory Manager procedures are called to obtain
a memory block of any size from the memory pool and to release it back to the pool when
it is no longer required.
When released, the memory is automatically returned by the Memory Manager to its
memory pool. A memory block use count is maintained to allow a single block to have
several owners and to prevent the block from being released until it is discarded by all
owners. Hence, more than one task can simultaneously own a shared piece of memory.
If a memory block is owned by more than one task, it is only returned to the memory
pool when the slowest owner finally releases it.
The AMX Memory Manager maintains a single memory pool. The amount of memory in
the pool is limited only by memory availability.
A particular unique feature of the Memory Manager permits any block of memory
(including those acquired from the memory pool controlled by the Memory Manager) to
be treated as a separate memory section from which smaller private blocks can be
dynamically allocated. This feature allows a task which has well defined memory
requirements to reserve a memory block for its own private use. The task can then call
on the Memory Manager to control the allocation and release of smaller blocks from
within the larger private block.
Note
The AMX 86 Memory Manager provides fast and efficient
allocation of paragraph (16-byte) aligned blocks of memory
for 80x86 systems with 16-bit memory addressing.
When used with the VAutomation Turbo86 processors with
24-bit memory addressing, memory blocks are allocated
with 16-byte alignment, not page (256 byte) alignment.
For additional information, see the AMX 86 Tool Guide for
Paradigm toolset PX.