Stack

orelavi wrote on Monday, March 17, 2008:

Hello

I read the the documents about FreeRTOS and i have a some questions
concerning the stack.

I saw that when i call to : xTaskCreate(…) i have to give it a
stack depth parameter.
- What will be saved in this stack?
- Is it true that this stack is create by memory allocation?
- In a context switch the regs,flags,… will be saved to the stack,
how this RTOS handle and position this data to every task?

Thanks

davedoors wrote on Monday, March 17, 2008:

The stack used by the task is just like any stack used in a C program. There is nothing special or different about it.

orelavi wrote on Monday, March 17, 2008:

So why do i need the stack depth parameter?

jmr1972 wrote on Tuesday, March 18, 2008:

You need to specify the stack size for each task so that the OS can reserve this amount from the available heap memory.
The compiler only knows about stack pointer it doesn’t do any per task stack allocation. This is done by the RTOS, which doesn’t know how much memory a particular task will require during runtime…