mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/freertos_stack_tcb_alloc_order' into 'master'
freertos: fix allocation order for stack and TCB per portSTACK_GROWTH See merge request espressif/esp-idf!18042
This commit is contained in:
commit
dec3db6913
@ -159,9 +159,24 @@ void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer,
|
|||||||
{
|
{
|
||||||
StaticTask_t *pxTCBBufferTemp;
|
StaticTask_t *pxTCBBufferTemp;
|
||||||
StackType_t *pxStackBufferTemp;
|
StackType_t *pxStackBufferTemp;
|
||||||
|
|
||||||
|
/* If the stack grows down then allocate the stack then the TCB so the stack
|
||||||
|
* does not grow into the TCB. Likewise if the stack grows up then allocate
|
||||||
|
* the TCB then the stack. */
|
||||||
|
#if (portSTACK_GROWTH > 0)
|
||||||
|
{
|
||||||
//Allocate TCB and stack buffer in internal memory
|
//Allocate TCB and stack buffer in internal memory
|
||||||
pxTCBBufferTemp = pvPortMallocTcbMem(sizeof(StaticTask_t));
|
pxTCBBufferTemp = pvPortMallocTcbMem(sizeof(StaticTask_t));
|
||||||
pxStackBufferTemp = pvPortMallocStackMem(configIDLE_TASK_STACK_SIZE);
|
pxStackBufferTemp = pvPortMallocStackMem(configIDLE_TASK_STACK_SIZE);
|
||||||
|
}
|
||||||
|
#else /* portSTACK_GROWTH */
|
||||||
|
{
|
||||||
|
//Allocate TCB and stack buffer in internal memory
|
||||||
|
pxStackBufferTemp = pvPortMallocStackMem(configIDLE_TASK_STACK_SIZE);
|
||||||
|
pxTCBBufferTemp = pvPortMallocTcbMem(sizeof(StaticTask_t));
|
||||||
|
}
|
||||||
|
#endif /* portSTACK_GROWTH */
|
||||||
|
|
||||||
assert(pxTCBBufferTemp != NULL);
|
assert(pxTCBBufferTemp != NULL);
|
||||||
assert(pxStackBufferTemp != NULL);
|
assert(pxStackBufferTemp != NULL);
|
||||||
//Write back pointers
|
//Write back pointers
|
||||||
@ -184,9 +199,24 @@ void vApplicationGetTimerTaskMemory(StaticTask_t **ppxTimerTaskTCBBuffer,
|
|||||||
{
|
{
|
||||||
StaticTask_t *pxTCBBufferTemp;
|
StaticTask_t *pxTCBBufferTemp;
|
||||||
StackType_t *pxStackBufferTemp;
|
StackType_t *pxStackBufferTemp;
|
||||||
|
|
||||||
|
/* If the stack grows down then allocate the stack then the TCB so the stack
|
||||||
|
* does not grow into the TCB. Likewise if the stack grows up then allocate
|
||||||
|
* the TCB then the stack. */
|
||||||
|
#if (portSTACK_GROWTH > 0)
|
||||||
|
{
|
||||||
//Allocate TCB and stack buffer in internal memory
|
//Allocate TCB and stack buffer in internal memory
|
||||||
pxTCBBufferTemp = pvPortMallocTcbMem(sizeof(StaticTask_t));
|
pxTCBBufferTemp = pvPortMallocTcbMem(sizeof(StaticTask_t));
|
||||||
pxStackBufferTemp = pvPortMallocStackMem(configTIMER_TASK_STACK_DEPTH);
|
pxStackBufferTemp = pvPortMallocStackMem(configTIMER_TASK_STACK_DEPTH);
|
||||||
|
}
|
||||||
|
#else /* portSTACK_GROWTH */
|
||||||
|
{
|
||||||
|
//Allocate TCB and stack buffer in internal memory
|
||||||
|
pxStackBufferTemp = pvPortMallocStackMem(configTIMER_TASK_STACK_DEPTH);
|
||||||
|
pxTCBBufferTemp = pvPortMallocTcbMem(sizeof(StaticTask_t));
|
||||||
|
}
|
||||||
|
#endif /* portSTACK_GROWTH */
|
||||||
|
|
||||||
assert(pxTCBBufferTemp != NULL);
|
assert(pxTCBBufferTemp != NULL);
|
||||||
assert(pxStackBufferTemp != NULL);
|
assert(pxStackBufferTemp != NULL);
|
||||||
//Write back pointers
|
//Write back pointers
|
||||||
|
@ -54,8 +54,9 @@ TaskHandle_t pxTaskGetNext( TaskHandle_t pxTask );
|
|||||||
* does not acquire any locks.
|
* does not acquire any locks.
|
||||||
* @param[in] pxTask Task's handle
|
* @param[in] pxTask Task's handle
|
||||||
* @param[out] pxTaskSnapshot Snapshot of the task
|
* @param[out] pxTaskSnapshot Snapshot of the task
|
||||||
|
* @return pdTRUE if operation was successful else pdFALSE
|
||||||
*/
|
*/
|
||||||
void vTaskGetSnapshot( TaskHandle_t pxTask, TaskSnapshot_t *pxTaskSnapshot );
|
BaseType_t vTaskGetSnapshot( TaskHandle_t pxTask, TaskSnapshot_t *pxTaskSnapshot );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Fill an array of TaskSnapshot_t structures for every task in the system
|
* @brief Fill an array of TaskSnapshot_t structures for every task in the system
|
||||||
|
@ -162,14 +162,17 @@ TaskHandle_t pxTaskGetNext( TaskHandle_t pxTask )
|
|||||||
return pxNextTCB;
|
return pxNextTCB;
|
||||||
}
|
}
|
||||||
|
|
||||||
void vTaskGetSnapshot( TaskHandle_t pxTask, TaskSnapshot_t *pxTaskSnapshot )
|
BaseType_t vTaskGetSnapshot( TaskHandle_t pxTask, TaskSnapshot_t *pxTaskSnapshot )
|
||||||
{
|
{
|
||||||
configASSERT( portVALID_TCB_MEM(pxTask) );
|
if (portVALID_TCB_MEM(pxTask) == false || pxTaskSnapshot == NULL) {
|
||||||
configASSERT( pxTaskSnapshot != NULL );
|
return pdFALSE;
|
||||||
|
}
|
||||||
|
|
||||||
TCB_t *pxTCB = (TCB_t *)pxTask;
|
TCB_t *pxTCB = (TCB_t *)pxTask;
|
||||||
pxTaskSnapshot->pxTCB = pxTCB;
|
pxTaskSnapshot->pxTCB = pxTCB;
|
||||||
pxTaskSnapshot->pxTopOfStack = (StackType_t *)pxTCB->pxTopOfStack;
|
pxTaskSnapshot->pxTopOfStack = (StackType_t *)pxTCB->pxTopOfStack;
|
||||||
pxTaskSnapshot->pxEndOfStack = (StackType_t *)pxTCB->pxEndOfStack;
|
pxTaskSnapshot->pxEndOfStack = (StackType_t *)pxTCB->pxEndOfStack;
|
||||||
|
return pdTRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
UBaseType_t uxTaskGetSnapshotAll( TaskSnapshot_t * const pxTaskSnapshotArray, const UBaseType_t uxArrayLength, UBaseType_t * const pxTCBSize )
|
UBaseType_t uxTaskGetSnapshotAll( TaskSnapshot_t * const pxTaskSnapshotArray, const UBaseType_t uxArrayLength, UBaseType_t * const pxTCBSize )
|
||||||
|
@ -138,7 +138,8 @@ TEST_CASE("Task snapshot: Iterate", "[freertos]")
|
|||||||
TaskHandle_t cur_task_handle = pxTaskGetNext(NULL);
|
TaskHandle_t cur_task_handle = pxTaskGetNext(NULL);
|
||||||
while (cur_task_handle != NULL) {
|
while (cur_task_handle != NULL) {
|
||||||
// Get the task's snapshot
|
// Get the task's snapshot
|
||||||
vTaskGetSnapshot(cur_task_handle, &task_snapshots[num_snapshots]);
|
BaseType_t Result = vTaskGetSnapshot(cur_task_handle, &task_snapshots[num_snapshots]);
|
||||||
|
TEST_ASSERT_EQUAL(pdTRUE, Result);
|
||||||
num_snapshots++;
|
num_snapshots++;
|
||||||
cur_task_handle = pxTaskGetNext(cur_task_handle);
|
cur_task_handle = pxTaskGetNext(cur_task_handle);
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ Tasks Snapshot
|
|||||||
|
|
||||||
The header ``task_snapshot.h`` has been removed from ``freertos/task.h``. ESP-IDF developers should include ``"freertos/task_snapshot.h``` in case they need tasks snapshot API.
|
The header ``task_snapshot.h`` has been removed from ``freertos/task.h``. ESP-IDF developers should include ``"freertos/task_snapshot.h``` in case they need tasks snapshot API.
|
||||||
|
|
||||||
|
The function :cpp:func:`vTaskGetSnapshot` now returns ``BaseType_t``. Return value shall be ``pdTRUE`` on success and ``pdFALSE`` otherwise.
|
||||||
|
|
||||||
FreeRTOS Asserts
|
FreeRTOS Asserts
|
||||||
----------------
|
----------------
|
||||||
|
Loading…
Reference in New Issue
Block a user