Task stack size

s.allasia
Posts: 23
Joined: Tue Jan 09, 2018 3:12 pm

Task stack size

Postby s.allasia » Mon Jan 22, 2018 9:38 am

Hi,

How I can determine a stack size when I create a task (xTaskCreate)?
Can you tell me what factors need to be consider for calculating a task stack size?

Thanks!

f.h-f.s.
Posts: 214
Joined: Thu Dec 08, 2016 2:53 pm

Re: Task stack size

Postby f.h-f.s. » Mon Jan 22, 2018 10:24 am

You need the stack space for all the variables in the scope of that task. (not including malloc, which goes on the heap)
You can see how much of that space is/was used by calling "uxTaskGetStackHighWaterMark(NULL)" inside the task. Or passing the task handle instead of NULL, calling the function from anywhere.

s.allasia
Posts: 23
Joined: Tue Jan 09, 2018 3:12 pm

Re: Task stack size

Postby s.allasia » Mon Jan 22, 2018 2:15 pm

Ok, thanks I tried that you suggested to me.
So do I have to find the value empirically?

User avatar
Gfast2
Posts: 182
Joined: Fri Aug 11, 2017 1:52 am

Re: Task stack size

Postby Gfast2 » Thu Jan 25, 2018 11:55 am

I start with a safe / big enough stack size, then try to call
uxTaskGetStackHighWaterMark(NULL)
monitor how is the "High Water Mark", then lastely I shrink down the stack size I allocated before. 8192 is what I tried first normally.

Cheers

Gfast2

s.allasia
Posts: 23
Joined: Tue Jan 09, 2018 3:12 pm

Re: Task stack size

Postby s.allasia » Thu Jan 25, 2018 12:25 pm

Ok, thanks a lot Gfast2!
I do in your way.

Who is online

Users browsing this forum: No registered users and 133 guests