Quality RTOS & Embedded Software

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


Task local variables

Posted by Peter Nielsen on November 24, 2008

My question:
if i use a lot of local variables in a taskA - i.e. some of them are in CPU registers and some are put on the stack (thats how memory normally are allocated).

Now a higher priority taskB preemtives taskA and do some job and returns control to taskA.

When taskA runs again are all local variables valid or do i have to declare them static - i asume them in Cpu regs. are restored but what about the local vars. which where stored on the stack in taskA ???????

RE: Task local variables

Posted by Jesper Matthiesen on November 24, 2008
yes, all registers are saved on the stack before a context switch and restored afterwards, so your vars will be intact..

[ 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.0 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.


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


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