This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

SYSLINK: Meaning of MADUs in heap modules

Hello,

i am wondering, what a size in MADUs is when e.g. using HeapBufMP in SYSLINK. When i read the API documentation of e.g. the function "HeapBufMP_alloc", the parameter "size" has the unit "MADU". Is this a muliple of the block size i specified in the HeapBufMP_Params structure when creating the HeapBufMP instance or do  i have to specify the size in bytes?

By the way, i tried to test it by reading back the heap status using "HeapBufMP_getExtendedStats" but the result was always 0, even after allocating some buffers on the heap. And what does the function "HeapBufMP_getStats" return? There is no structure defined fot the returned "stats" parameter.

Thanks in advance,

Dom

  • MADU is Minimum Addressable Data Unit. This unit is normally in 8 bit bytes for most targets except for the C28 family which has a MADU of 16 bits.

    The getStats and getExtendedStats APIs require you to pass a pointer to a corresponding stats object that the API then fills up.

    Both APIs return Voids.

    The extended stats structure is defined in the HeapBufMP.h file:

    /*!
     *  @brief  Stats structure for the HeapBufMP_getExtendedStats API.
     */
    typedef struct HeapBufMP_ExtendedStats {
        UInt maxAllocatedBlocks;
        /*!< The maximum number of blocks allocated from this heap at any point in
         *  time during the lifetime of this HeapBufMP instance.
         */
         
        UInt numAllocatedBlocks;
        /*!< The total number of blocks currently allocated in this HeapBufMP
         *  instance.
         */
    } HeapBufMP_ExtendedStats;

    The Memory_Stats type is inherited by and defined in the xdc.runtime.Memory.h file:

    /* Stats */
    struct xdc_runtime_Memory_Stats {
        xdc_runtime_Memory_Size totalSize;
        xdc_runtime_Memory_Size totalFreeSize;
        xdc_runtime_Memory_Size largestFreeSize;
    };

    Alan

  • Dom,

    I would like to add, that when allocating from a HeapBufMP object, the size should not be greater than the block size that the HeapBufMP object was created with.  If the HeapBufMP object was created with HeapBufMP_Params.exact = TRUE, then the size must equal the block size.

    If you want to call HeapBufMP_getStats() from the Linux side, you can include the header file:

       #include <ti/syslink/utils/Memory.h>

    to get the Memory_Stats structure definition.

    The HeapBufMP_getStats() function normally returns the block size in Memory_Stats.largestFreeSize, but in SysLink, the HeapBufMP module has tracking of allocations turned off for performance reasons.  The HeapBufMP object is in shared memory and can be used by multiple processors, so tracking allocations requires some more cache maintenance.  However, if you would like to track allocations, the easiest way to do this is by editing the file:

    ti/syslink/ipc/hlos/knl/HeapBufMP.c, and changing the 'trackAllocs' field in the HeapBufMP_state structure to TRUE:

    HeapBufMP_ModuleObject HeapBufMP_state =
    {
        .defaultCfg.maxNameLen            = 32u,
        .defaultCfg.maxRunTimeEntries     = 32u,
        .defaultCfg.trackAllocs           = TRUE,
        .defaultInstParams.gate           = NULL,
        .defaultInstParams.exact          = FALSE,
        .defaultInstParams.name           = NULL,
        .defaultInstParams.align          = 1u,
        .defaultInstParams.numBlocks      = 0u,
        .defaultInstParams.blockSize      = 0u,
        .defaultInstParams.regionId       = 0u,
        .defaultInstParams.sharedAddr     = NULL,
    };

    Then you would need to rebuild the syslink driver.

    Best regards,

        Janet

  • Janet,

    thanks for that additional information. I think thats the reason the getStats() funtion returned always 0.

    Best regards,

    Dom