AN2345 Freescale Semiconductor / Motorola, AN2345 Datasheet - Page 17

no-image

AN2345

Manufacturer Part Number
AN2345
Description
Real-Time Memory Manager for StarCore DSPs
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
After identifying the memory block sizes an application requires, the worst-case allocation of these
blocks, and the location of the heaps, you are finally ready to allocate the heaps. It is not necessary to
allocate the heaps statically all at once. VSMM allows dynamic creation of heaps so that the programmer
can eliminate a heap with a memory block of one size and create another heap with a different memory
block size. In addition, VSMM allows programmers to partition a memory block of a heap, therefore
creating a second heap with memory blocks of a smaller size than the heap from which the block was
allocated. A heap cannot be eliminated until all of its associated memory blocks are freed.
To determine the memory usage the VSMM requires for your heaps, you must consider the overhead
associated with the VSMM. The overhead for each heap is 24 bytes for the MCB. Therefore, if you
defined the VSMM_MAX_MEM_PART #define constant to a value of five times the total memory for
the MCBs, 5
By default, the memory area in which the MCB allocations occur extends from either your designated
system’s data space, if statically declared, or from the system stack space if locally declared. It does not
extend from the designated system heap space because the heap space is consumed only through dynamic
memory allocations. The overhead associated with each memory block is at least 8 bytes
(VSMM_MEMBLK_HDR_SIZE). However, if your block size is not 8-byte aligned, additional overhead
is added to ensure this alignment. BALIGN is a VSMM macro that returns an equivalent 8-byte aligned
block size based on the block size specified:
actual block size (ABS) = BALIGN(desired block size (in bytes))
Therefore to determine the total heap size, use the following algorithm:
Freescale Semiconductor, Inc.
For More Information On This Product,
Figure 10. System Stack and Heap Space
24-bytes equals 120 bytes.
Go to: www.freescale.com
0x500000
0x700000
0 x5 0 0 0 0
0 x5 0 0 0 0
0 x7 0 0 0 0
0 x7 0 0 0 0
Stack Start
Heap Start
Stack Sta rt
Stac Start
H eap Sta rt
H eap Sta rt
Stack Used
Free
Heap Used
Sta ck U sed
Free
H ea p U sed
Building Your Application with VSMM
17

Related parts for AN2345