FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! 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.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [August 2008 Threads] How are stacks allocated for new tasks in ARMPosted 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 ARMPosted 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 ARMPosted 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 ARMPosted 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 ?
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|