Skip to main content
Graduate
September 18, 2024
Solved

Watermark in Azure ThreadX?

  • September 18, 2024
  • 1 reply
  • 1816 views

Greetings and thanks for reading. 

FreeRTOS has a built in utility function uxTaskGetStackHighWaterMark() that reports on the amount of space unused by the stack.   You can use this function to gauge just how much of the stack is used and how close you are to corruption or conversely how much memory you are wasting.  Its a way of both preventing crashes (due to blown stacks) and simultaneous allowing you to optimize the size of the stack for applications that may be tight on memory.  

Within the Azure ThreadX I could find no such function that will report such useful information.  Is there such a utility within ThreadX that I can call?

Thanks,

Hab

    This topic has been closed for replies.
    Best answer by Hab Collector

    Thank you for responding.  That's not exactly what I was looking for, but I think something I can use all the same.  In retrospect I got hung up searching for the term "water-mark" in the documentation.  

    Thanks,

    Hab

    1 reply

    ST Employee
    September 19, 2024

    Hello @Hab Collector ,

    you can find a lot of APIs dedicate to thread usage analyses and error detection related to ThreadX .

    see the following threadx/common/inc/tx_api.h at master · eclipse-threadx/threadx (github.com)

    /* Define the random stack fill number. This can be used to detect stack overflow. */
    ULONG tx_thread_stack_fill_value;
    
    #define tx_thread_stack_error_notify _tx_thread_stack_error_notify
    
    
    
    /* Add a default macro that can be re-defined in tx_port.h to add processing to the thread stack analyze function.
    By default, this is simply defined as whitespace. */
    
    #ifndef TX_THREAD_STACK_ANALYZE_EXTENSION
    
    #define TX_THREAD_STACK_CHECK(a)

    here are some examples from the TX_API.h file. Also, in CubleIDE you can find the extension for viewing ThreadX threads memory semaphores Stack usages and other related information using the Serial wire viewer feature.
    Hope this might help you.
    Regards

    Hab CollectorAuthorAnswer
    Graduate
    September 20, 2024

    Thank you for responding.  That's not exactly what I was looking for, but I think something I can use all the same.  In retrospect I got hung up searching for the term "water-mark" in the documentation.  

    Thanks,

    Hab