Stack Size in TASK_TEMPLATE_STRUCT

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Stack Size in TASK_TEMPLATE_STRUCT

跳至解决方案
726 次查看
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

标记 (2)
0 项奖励
1 解答
491 次查看
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 项奖励
1 回复
492 次查看
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 项奖励