Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Loading

xStackCreate

Posted by michaeln32 on January 15, 2018

Can you please tell me what are the values that initial the stack of a task whae it create (xTaskCreate) ?

Are those values the general purpose registers ?


xStackCreate

Posted by rtel on January 15, 2018

To my knowledge there is no function 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

Posted by michaeln32 on January 15, 2018

Richard, Thank you very much.

  1. Are local variables of a task are saves on the task stack too ? If they do, Are the local variables that saved in the stack are saved after the MCU registers or before the MCU registers ?

  2. 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 ?

Thank you !

Michael


xStackCreate

Posted by rtel on January 15, 2018
Are local variables of a task are saves on the task stack too ? 

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

Posted by michaeln32 on January 15, 2018

I have this task:

void Task(void *arg) { char stackBufferLcl[100];

while(1)
{
	vTaskDelay(5000);
}

}

When I call the API vTaskList() I see that the stack memory usege has grown in 100 bytes. So i asume that local varialbes of task do saves in task stack


xStackCreate

Posted by rtel on January 15, 2018

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.


[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner