Quality RTOS & Embedded Software

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


Loading

How are stacks allocated for new tasks in ARM

Posted by Angel Eyes on August 19, 2008
How are stacks allocated during task creation in ARM 7TDMI architecture, as I understand the stack areas are created during startup in the boot code for each mode. Now, during creation of a task , what more happens ? I am aware that the TCB space is allocated from the heap but what about the task stack ? What is the necessity of explicitly allocating a stack space after allocationg it in the startup code anyway.

I believe during an RTOS tick or an interrupt the stack pointer of the current mode of the processor will be used anyway to save context . Could someone point out in which section of the source code we have the part which reserves stack space on task creation ?

What I missing out here ?

Thanks in advance .

RE: How are stacks allocated for new tasks in ARM

Posted by Richard Damon on August 19, 2008
First, the reason you need a stack for each task is to have a place to store the state of each task, including all the auto variables used by that task.

The stacks are set up inside of the Create Task function, and the Yield function does the actual stack switching.

RE: How are stacks allocated for new tasks in ARM

Posted by David Farrell on August 20, 2008

The function call in task.c says it all. prvAllocateTCBAndStack() this calls pvPortMalloc() this
is pretty easy to find if you review task.c I found it helps to understand how the first task
is set up and how is stack is prepared. Note that the first task is started as if returning from
the context pushed by pxPortInitialiseStack.

Review pxPortInitialiseStack in the port.c file. If this initial stack frame is setup correctly,
(and it is easy to debug with any debugger since no interrupts yet) your port of FreeRTOS will run.
Lastly review a sample portSAVE_CONTEXT() to understand the difference between the Arm and
FreeRTOS task stacks.

Richard did a nice job commenting the source, I think you questions are best answered there.

David.

RE: How are stacks allocated for new tasks in ARM

Posted by Angel Eyes on August 20, 2008
Thanks for your answers , I will definitely work on this . I admit I am new to this as of now . If I get a hang of this , I would like to make some contribution in the form of documentation , where I would like to describe the function call flow during initialisation, the stack usage , basically how the RTOS initialises . I am not sure when really :) but I would definitely try it . Right now I might not be able to understand the scheduler functionalities , so cant promise documentation on those .

Would such a contribution be accepted ?


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


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

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

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