Stack Size in TASK_TEMPLATE_STRUCT

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Stack Size in TASK_TEMPLATE_STRUCT

Jump to solution
715 Views
csmgsarma
Contributor IV

Hi List,

1. What is the need for stack size in this structure? Some RTOS flavors don't need this parameter.

2. How can a programmer choose his stack size optimally?

3. How can the stack usage be checked?

Regards

Sarma

Tags (2)
0 Kudos
1 Solution
480 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Sarma:

1)  A proper configuration of the stack is essential to your system stability and reliability. If the stack size is too small, stack pointer might be moved out of the stack area thus an overflow situation occurs. In this case, the executing code could write to the area allocated  below the stack and lead to a serious runtime failure like overwritten variables, wild pointers, courrupted retrun address etc. On the other hand, setting the stack size too large means a waster of RAM resource which could be very limited in MCU-base embedded system.

I think you can google more for this topic.

2 & 3),MQX provided a tool , TAD (Task Aware Debugger) can analyze the stack usage.

Please read the below document for more details

C:\Freescale\Freescale_MQX_4_2\doc\tools\cw\MQX_RuntimeTAD_Getting_Started.pdf

please also check this thread for how to determine the task size

How to determine the task Stack size 

Best Regards

Daniel



-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
1 Reply
481 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Sarma:

1)  A proper configuration of the stack is essential to your system stability and reliability. If the stack size is too small, stack pointer might be moved out of the stack area thus an overflow situation occurs. In this case, the executing code could write to the area allocated  below the stack and lead to a serious runtime failure like overwritten variables, wild pointers, courrupted retrun address etc. On the other hand, setting the stack size too large means a waster of RAM resource which could be very limited in MCU-base embedded system.

I think you can google more for this topic.

2 & 3),MQX provided a tool , TAD (Task Aware Debugger) can analyze the stack usage.

Please read the below document for more details

C:\Freescale\Freescale_MQX_4_2\doc\tools\cw\MQX_RuntimeTAD_Getting_Started.pdf

please also check this thread for how to determine the task size

How to determine the task Stack size 

Best Regards

Daniel



-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos