cancel
Showing results for 
Search instead for 
Did you mean: 

Watermark in Azure ThreadX?

Hab Collector
Associate III

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

1 ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

6 REPLIES 6
STea
ST Employee

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

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

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

Just : i dont get this working:

@STea  :  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.

But (for me) : stack usage shows nothing:

AScha3_0-1726835359144.png

 

What i have to do, to see it ?

 

 

If you feel a post has answered your question, please click "Accept as Solution".

Stack usage for me also shows nothing, what I was previously doing to check for potential errors was looking at the Stack Start and Stack End and the Stack Ptr - checking to see the Stack Ptr was within said range.  You can only do this on break points so in all this was not very effective.  Yes it would be nice to see stack usage here - I guess that would be a type of water mark.  

Hello @AScha.3 ,

check this video minutes 26 (284) MOOC - Azure RTOS workshop - 5 ThreadX lab - step1 - First thread creation - YouTube
you need to click on green table on the right corner to enable it.
Regards 

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Thanks @STea  ,

AScha3_0-1726849327446.png

 

this click was the secret. Now :

AScha3_0-1726843533845.png

:)

:)

 

:)

Great !

If you feel a post has answered your question, please click "Accept as Solution".