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] [January 2012 Threads] Question about Task Stack itemsPosted by Dimitry on January 3, 2012 Hi,
MCU: EFM32 (EnergyMicro Cortex M3) FreeRTOS 7.0.1
I check stack allocation in function xTaskGenericCreate() and pxPortInitialiseStack(), for example:
TOP of stack = 0x200008CC, aligned TOP of stack = 0x200008C8
Aligned TOP of Stack value – 4 bytes(0x200008C4) portINITIAL_XPSR Aligned TOP of Stack value – 8 bytes(0x200008C0) pointer to task function Aligned TOP of Stack value – 12 bytesLR Aligned TOP of Stack value – 16 bytesR12(reserved for use in future) Aligned TOP of Stack value – 20 bytesR3(reserved for use in future) Aligned TOP of Stack value – 24 bytesR2(reserved for use in future) Aligned TOP of Stack value – 28 bytesR1(reserved for use in future) Aligned TOP of Stack value – 32 bytespointer to parameters, passed to the Task Function Aligned TOP of Stack value – 36 bytesR11(reserved for use in future) Aligned TOP of Stack value – 40 bytesR10(reserved for use in future) Aligned TOP of Stack value – 44 bytesR9(reserved for use in future) Aligned TOP of Stack value – 48 bytesR8(reserved for use in future) Aligned TOP of Stack value – 52 bytesR7(reserved for use in future) Aligned TOP of Stack value – 56 bytesR6(reserved for use in future) Aligned TOP of Stack value – 60 bytesR5(reserved for use in future) Aligned TOP of Stack value – 64 bytes (0x20000888)R4(reserved for use in future)
When the Task Function is called by system, firstly a values of R4 and LR is pushed to stack:
void TaskFunction(void *pvParameters) { TaskFunction: 0x14c22: 0xb510 PUSH {R4, LR} .....
Them pushed at address 0x200008C4 (LR) and 0x200008C0 (R4) and completely overwrite the portINITIAL_XPSR and pointer to the task function values.
Does it correct behavior? Can I analyze the stack area (R1 .. R12 values stored in the stack as reserved in pxPortInitialiseStack() function) after context switch or this area is "not for use"?
Best Regards and thanks for support.
RE: Question about Task Stack itemsPosted by Richard on January 3, 2012 The items are pushed onto the stack before the stack is started to allow the stack to be started. That is, the items are popped from the stack during the processor starting the task. Once they have been popped from the stack, and the task is running, the stack frame as initially configured is no longer required and a new stack frame is created by the task function entry code (the compiler generated prologue). The tasks stack frame will overwrite the original stack frame, so this behaviour is correct.
Regards.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|