FreeRTOS Support Archive

The FreeRTOS support forum can be used for active support both from Amazon Web Services
and the community. In return for using our software for
free, we request you play fair and do your bit to help others! Sign up
to receive notifications of new support topics then help where you can.

This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.

xStackCreate

Each task has its own stack and its own set of MCU registers. When a
task is swapped out (stops executing to allow a different task to run)
the task's registers are saved onto its stack. When it starts running
again its registers are popped off its stack so it can continue
executing with exactly the same MCU context as when it stopped.

The stack used by a task is created when the task is created, and then
initialized to make it look like the task had been swapped out - so the
values placed onto the stack when the task is created are the values
that the task will pop off the stack into the MCU registers when it
first executes.

xStackCreate

Where local variables are saved is completely under the control of the
compiler you are using. FreeRTOS is just C code, compiled along with
the rest of your application - it cannot change how the processor or the
compiler work.

Where can I find what is the order of the MCU registers are saved in
the stack of a task, and what are the registers that are saved ?

Have a look at the port layer source code. The initial stack is created
by vPortInitialiseStack() in each port.c file - but that might not tell
you much (depending on the port). Otherwise look at the code that saves
and restores the context, which will be in the same port.c file or in an
assembly file in the same directory as the port.c file.

xStackCreate

If you want to know where local variables are stored you should consult
your compiler's manual. 100 bytes its almost certain to go on the
stack. If it were 4 bytes then it would probably be stored in a register.