EasyManuals Logo

Texas Instruments TMS320 User Manual

Texas Instruments TMS320
288 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #187 background imageLoading...
Page #187 background image
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);

Table of Contents

Other manuals for Texas Instruments TMS320

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Texas Instruments TMS320 and is the answer not in the manual?

Texas Instruments TMS320 Specifications

General IconGeneral
BrandTexas Instruments
ModelTMS320
CategoryComputer Hardware
LanguageEnglish

Related product manuals