Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




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 ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists