Task or software timer?

I have a background task which is doing a bit of housekeeping and is run every 500ms. It has the lowest priority in the system and I created it in preference to using the idel task as I want to use that for something else. However, it seems a bit of a waste of resources as it needs a stackof its own, so I thought about replacing the task with a software timer but when I looked into it that too seems to need a stack? So I’m not exactly sure what I stand to gain and I’m a little confused as to why it needs a stack, after all it’s just running a callback when the timer expires???
Thanks, Paul.

Task or software timer?

Software timers themselves don’t need any more stack than a standard C function.  However, software timer callbacks run in the context of the timer task.  The timer task does need a stack (just like any other task), but there is only one timer task.  Therefore, if you have 1 software timer or 10 software, the amount of additional stack required is the same. Regards.

Task or software timer?

Okay, thanks for the clarification. I noticed that even if you create a stack size of 1 the OS will set a minimum stack size of 256 and that 256 means the number of 4 byte words not bytes. So in effect the minimum stack size is 1Kb – is my understanding correct? Thanks, Paul.

Task or software timer?

is my understanding correct
No.  I don’t know where you have got that from. The timer task stack is set by configTIMER_TASK_STACK_DEPTH and is specified in words, just like any other task.  It should not be set below configMINIMAL_STACK_SIZE, and in fact even that might be too small. Regards.

Task or software timer?

But configMINIMAL_STACK_SIZE is hash defined as 256 in the config header file? And in the documentation for the function xTaskreate() it says that the stack size is the number of words not the number of bytes? Regards, Paul.

Task or software timer?

What you originally stated was:
I noticed that even if you create a stack size of 1 the OS will set a minimum stack size of 256
…and that is not correct.  The OS will set whatever you set  configTIMER_TASK_STACK_DEPTH to. 256 sounds like a large minimal stack value – which port are you using?  Check the setting in the official demo for the port as it could well be smaller. Regards.

Task or software timer?

Okay thanks, will do. Regards, Paul.

Task or software timer?

Looking back it seems as though I got the stack size of 256 from one of the examples and never changed it. The demo for my port (AVR32) has a size of 128. Was I right in saying that’s words not bytes though? Is a task’s stack used purely for local variables and any parameters passed into that task or does the OS use it behind the scenes? I’m just trying to get a feel for what size I should make it. I know there are some hooks that I can implement to monitor the stack size which I’ll do in the future. Thanks, Paul.