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 2016 Threads] How to see upper/lower bound of a task's stack?Posted by awillson on January 15, 2016 Hello,
I am working on a RAM test routine that needs to skip the current RTOS task's stack.
How can I retrieve the current task's upper/lower stack boundary?
Thanks!
How to see upper/lower bound of a task's stack?Posted by rtel on January 15, 2016 This is not easy at the moment, although we are already working on a function that will extend the uxTaskGetSystemState() function to return stack boundaries too (and to allow it to be called on a task by task basis) - plus the current head revision allows task stacks to be allocated statically so you always know where they are.
In the mean time, assuming you are using an architecture for which the stack grows down, you can obtain the limit of the stack by adding the following function to the tasks.c. You pass in a task handle, or NULL if you are querying the stack limit of the calling task. The stack size will be known as it was a parameter passed into the function that created the stack (in words, not bytes!).
~~~~
StackTypet *pxTaskGetStackStart( TaskHandlet xTask )
{
TCB_t *pxTCB;
/* If null is passed in here then it is the stack of the calling task that
is being queried. */
pxTCB = prvGetTCBFromHandle( xTask );
return ( pxTCB->pxStack );
}
~~~~
How to see upper/lower bound of a task's stack?Posted by awillson on January 15, 2016 Hello RTE.
I'm getting a hardfault on the return() statement. Are you sure this pointer is dereferenced correctly?
Also, the handle which I pass to this GetStackStart() function, is the handle which is returned to me by xTaskCreate() - correct?
vBISTSRAM1_Task_handle = xTaskCreate(vBISTSRAM1_Task,
(const char *) "vTaskBISTSRAM1",
configMINIMAL_STACK_SIZE, NULL, (tskIDLE_PRIORITY + 1UL),
(xTaskHandle *) NULL);
...
SRAM_BIST_Test(pxTaskGetStackStart(vBISTSRAM1_Task_handle), configMINIMAL_STACK_SIZE);
Thanks for your assistance.
How to see upper/lower bound of a task's stack?Posted by rtel on January 16, 2016 I didn't actually try running the code, just typed it into the post, but it looks ok. I suspect your problem is to to the following comments -
Also, the handle which I pass to this GetStackStart() function, is the handle which is returned to me by xTaskCreate() - correct?
No! Please read the documentation for the xTaskCreate() API function - the handle is passed out using the last parameter. The return value is simply a pass/fail indication, not a pointer.
http://www.freertos.org/a00125.html
How to see upper/lower bound of a task's stack?Posted by awillson on January 18, 2016 Thanks for your help. I mis-read the xTaskCreate() definition, sorry about that. The code you provided is working fine, and all is well now.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|