How to determine the task Stack size

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

How to determine the task Stack size

ソリューションへジャンプ
2,211件の閲覧回数
davidzhou
Contributor V

Hi,

I have K60 tower board, and am using Code Warrior 10.6.4 with MQX 4.2.

I have only two tasks.

TASK_TEMPLATE_STRUCT  MQX_template_list[] =
{
{ UART_TASK,     Uart_Task,  20000,   5,    "Uart", MQX_AUTO_START_TASK,     0,         0 },
{ MAIN_TASK,       Main_Task,  25000,   6, "Main", MQX_AUTO_START_TASK,       0,        0 },
{ 0 }
};
 

And I have increased stack size to 25000 for Main task. It still triggers stack overflow. I am wandering how to determine the stack size for safety of not getting overflowed. Is there anyway to optimize the code for smaller stack size?

Thank you,

David Zhou

0 件の賞賛
返信
1 解決策
1,541件の閲覧回数
danielchen
NXP TechSupport
NXP TechSupport

Hi David:

I think you can use MQX tool, TAD (Task Aware Debugging).

There are TAD plugins for Code warrior, IAR, and Keil IDEs.

The plugins add MQX menu into your debugger environment and allow you to display various information about MQX OS kernel like stack usage per task, system memory pools etc.

You can start with a safe stack size , and fine tune it, try to decrease it a little each time, until the stack usage to 80-90% and no overflow, then I think the stack size is OK now.

pastedImage_1.png

Regards

Daniel

元の投稿で解決策を見る

0 件の賞賛
返信
2 返答(返信)
1,542件の閲覧回数
danielchen
NXP TechSupport
NXP TechSupport

Hi David:

I think you can use MQX tool, TAD (Task Aware Debugging).

There are TAD plugins for Code warrior, IAR, and Keil IDEs.

The plugins add MQX menu into your debugger environment and allow you to display various information about MQX OS kernel like stack usage per task, system memory pools etc.

You can start with a safe stack size , and fine tune it, try to decrease it a little each time, until the stack usage to 80-90% and no overflow, then I think the stack size is OK now.

pastedImage_1.png

Regards

Daniel

0 件の賞賛
返信
1,541件の閲覧回数
davidzhou
Contributor V

Daniel,

Thank you. I will try TAD.

David Zhou

0 件の賞賛
返信