Memory Management
Memory and Low-level Functions
5-5
5.1.4
Allocating Memory Dynamically
DSP/BIOS provides functions in two modules for dynamic memory allocation:
MEM and BUF. The MEM module allocates variable-size blocks of memory.
The BUF module allocates fixed-size buffers from buffer pools.
5.1.4.1 Memory Allocation with the MEM Module
Basic storage allocation may be handled using MEM_alloc, whose
parameters specify a memory segment, a block size, and an alignment as
shown in Example 5-3. If the memory request cannot be satisfied, MEM_alloc
returns MEM_ILLEGAL.
Example 5-3.
Using MEM_alloc for System-Level Storage
The segid parameter identifies the memory segment from which memory is
to be allocated. This identifier can be an integer or a memory segment name
defined in the configuration.
The memory block returned by MEM_alloc contains at least the number of
minimum addressable data units (MADUs) indicated by the size parameter.
A minimum addressable unit for a processor is the smallest datum that can
be loaded or stored in memory. An MADU can be viewed as the number of
bits between consecutive memory addresses. The number of bits in an
MADU varies with different DSP devices, for example, the MADU for the
C5000 platform is a 16-bit word, and the MADU for the C6000 platform is an
8-bit byte.
The memory block returned by MEM_alloc starts at an address that is a
multiple of the align parameter; no alignment constraints are imposed if align
is 0. An array of structures might be allocated as shown in Example 5-4.
Example 5-4.
Allocating an Array of Structures
Ptr MEM_alloc(segid, size, align)
Int segid;
Uns size;
Uns align;
typedef struct Obj {
Int field1;
Int field2;
Ptr objArr;
} Obj;
objArr = MEM_alloc(SRAM, sizeof(Obj) * ARRAYLEN, 0);
Содержание TMS320 Series
Страница 1: ...TMS320 DSP BIOS v5 40 User s Guide Literature Number SPRU423G April 2009 ...
Страница 16: ...xvi ...
Страница 152: ...Tasks 4 48 Figure 4 12 Trace from Example 4 7 ...
Страница 168: ...Semaphores 4 64 Figure 4 14 Trace Results from Example 4 11 ...
Страница 202: ...5 20 ...
Страница 287: ...Index 9 Index Void 1 11 W words data memory 3 15 of code 1 5 wrapper function 2 29 ...
Страница 288: ...Index 10 Index ...