Texas Instruments TMS320 User Manual page 188

Dsp/bios v5.40
Hide thumbs Also See for TMS320:
Table of Contents

Advertisement

Memory Management
Example 5-5. Using MEM_free to Free Memory
Example 5-6. Freeing an Array of Objects
5.1.4.2 Memory Allocation with the BUF Module
5-6
Many DSP algorithms use circular buffers that can be managed more
efficiently on most DSPs if they are aligned on a power of 2 boundary. This
buffer alignment allows the code to take advantage of circular addressing
modes found in many DSPs.
If no alignment is necessary, align should be 0. MEM's implementation aligns
memory on a boundary equal to the number of words required to hold a
MEM_Header structure, even if align has a value of 0. Other values of align
cause the memory to be allocated on an align word boundary, where align is
a power of 2.
MEM_free frees memory obtained with a previous call to MEM_alloc,
MEM_calloc, or MEM_valloc. The parameters to MEM_free—segid, ptr, and
size—specify a memory segment, a pointer, and a block size respectively, as
shown in Example 5-5. The values of these parameters must be the same as
those used when allocating the block of storage.
Void MEM_free(segid, ptr, size)
Int segid;
Ptr ptr;
Uns size;
Example 5-6 displays a function call which frees the array of objects allocated
in Example 5-5.
MEM_free(SRAM, objArr, sizeof(Obj) * ARRAYLEN);
The BUF module maintains pools of fixed-size buffers. These buffer pools
can be created statically or dynamically. Dynamically-created buffer pools are
allocated from a dynamic memory heap managed by the MEM module. The
BUF_create function creates a buffer pool dynamically. Applications typically
create buffer pools statically when size and alignment constraints are known
at design time. Run-time creation is used when these constraints vary during
execution.
Within a buffer pool, all buffers have the same size and alignment. Although
each frame has a fixed length, the application can put a variable amount of
data in each frame, up to the length of the frame. You can create multiple
buffer pools, each with a different buffer size.

Advertisement

Table of Contents
loading

Table of Contents