Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 15 Next »

Memory segments API has been introduced with µC/LIB v1.38. They offer the possibility to create segments of memory at different locations and to allocate buffers from them.  

Three different functions are available to allocate memory from a memory segment:

FunctionDescriptionUse case
Mem_SegAlloc()General-purpose allocation function. Will provide a buffer aligned on a CPU word boundary and with no guaranteed padding.General purpose buffers and control data accessed only by the CPU.
Mem_SegAllocExt()Same as Mem_SegAlloc(), except that this function allows to specify an alignment. It will also provide the amount of required bytes in case the call fails because memory segment would overflow.General purpose buffers and control data accessed only by the CPU but that require specific alignment (example: task stacks).
Mem_SegAllocHW()Allocates a buffer using specified alignment. This function will also add padding at the end of the buffer according to the padding_align argument specified at the creation of the memory segment. This is particularly useful on systems that use cache memory as it allows to have nothing else than the buffer allocated on a cache line.Data buffers that can be copied via a DMA engine.

 

Example usage of memory segments

gives an example usage of memory segments. In this example, we attempt to create a memory segment and to allocate three buffers of 20 bytes from it using the three different segment allocation functions available. Following the listing is an examplation of the differences between these 3 buffers.

 

  • No labels