Persistence of task variable

Hi,
are local variables defined inside a task handler function persistent across multiple calls (i.e. as if they were defined as static)?

I assumed I need to define them as static if I wanted that persistence (like everywhere else in c) but perhaps the freeRTOS has some precompile directives that change that? I am asking because came across a post in a forum where they were storing the value across multiple invocations which seems strange. Or was it just wrong code?

Thank you

I’m not sure what you mean…
Variables are variables and their persistence / visibility is defined by the C/C++ standard. There is no hidden FreeRTOS magic.
The only basic thing managed by a multitasking OS like FreeRTOS are separate stacks for each task but in a transparent way and you don’t need to worry about. They’re just normal stacks.

Then that’s what I thought, just wrong coding of that example.

Thank you Hartmut

If the task is being created from a static TCB and Stack buffer, you may well get the appearance of value persisting between recreations of the task, but that is not promised. (I think you will need to turn off stack checking, or that code will clear the stack frame and wipe out the old information.

I presume you aren’t just mistaking a task having a loop, and the values being preserved between loops.

Thank you Richard,
no the task does not have a loop inside it. I think it was just a wrong piece of code.