AN2345 Freescale Semiconductor / Motorola, AN2345 Datasheet - Page 8

no-image

AN2345

Manufacturer Part Number
AN2345
Description
Real-Time Memory Manager for StarCore DSPs
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
VSMM Basics
8
When a heap is created, an MCB is removed from the free list and updated to reflect the characteristics of
the new heap. Each of the heap’s memory blocks is initialized so that it points to the next available
memory block within the heap. The last memory block within a heap contains a NULL. The header of the
first memory block is also initialized to the address of its heap (see Figure 4). Notice that the MCB
heapAddr element is set to NULL, indicating that this heap was created in free memory space and not
from a memory block of another heap.
When a heap is eliminated, the MCB is reinitialized and its free list pointer is set to the global free list
pointer. The global free list pointer is updated to point to this newly freed space.
When a memory block is allocated from a heap, the MCB global free list pointer is updated to point to the
next available memory block after the allocated space. When a memory block is freed, it is added back to
the head of the free list (see Figure 5). The MCB free list is then updated to point to this newly freed
memory block.
Figure 6 shows a memory block that is partitioned into another heap. The MCB heap handle is that of the
heap from which the block was allocated, and the MBH of the first memory block within this new heap is
initialized to this new heap handle. Figure 7 depicts the allocation of several memory blocks from the
two created heaps. Notice how each memory block header contains the heap handle of the heap from
which it was allocated. When each block is freed, it is returned to its respective heap, identified by this
handle. When the second heap is destroyed, its memory block is returned to the heap identified by its
MCB heap handle.
Heap Handle
0x10028
Freescale Semiconductor, Inc.
For More Information On This Product,
Figure 5. Memory Block Allocation
0x100A0
0x140A8
(void *)0
16384
Go to: www.freescale.com
4
3
0x140A8
MBH
0x100A0
0x180B0
Pointer to Memory Block
0x180B0
Allocated Memory Block
0x1C0B8
0x1C0B8
0x0

Related parts for AN2345