Support allocating stack from separate heap (#267)
The change adds support for allocating task stacks from separate heap. When configSTACK_ALLOCATION_FROM_SEPARATE_HEAP is defined as 1 in FreeRTOSConfig.h, task stacks are allocated and freed using pvPortMallocStack and vPortFreeStack functions. This allows the application writer to provide a separate allocator for task stacks. When configSTACK_ALLOCATION_FROM_SEPARATE_HEAP is defined as 0, task stacks are allocated and freed using FreeRTOS heap functions pvPortMalloc and vPortFree. For backward compatibility, configSTACK_ALLOCATION_FROM_SEPARATE_HEAP defaults to 0. Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
This commit is contained in:

committed by
GitHub

parent
81f5892105
commit
2a604f4a28
@ -896,6 +896,11 @@
|
||||
#define configSUPPORT_DYNAMIC_ALLOCATION 1
|
||||
#endif
|
||||
|
||||
#ifndef configSTACK_ALLOCATION_FROM_SEPARATE_HEAP
|
||||
/* Defaults to 0 for backward compatibility. */
|
||||
#define configSTACK_ALLOCATION_FROM_SEPARATE_HEAP 0
|
||||
#endif
|
||||
|
||||
#ifndef configSTACK_DEPTH_TYPE
|
||||
|
||||
/* Defaults to uint16_t for backward compatibility, but can be overridden
|
||||
|
@ -179,6 +179,14 @@ void vPortInitialiseBlocks( void ) PRIVILEGED_FUNCTION;
|
||||
size_t xPortGetFreeHeapSize( void ) PRIVILEGED_FUNCTION;
|
||||
size_t xPortGetMinimumEverFreeHeapSize( void ) PRIVILEGED_FUNCTION;
|
||||
|
||||
#if( configSTACK_ALLOCATION_FROM_SEPARATE_HEAP == 1 )
|
||||
void *pvPortMallocStack( size_t xSize ) PRIVILEGED_FUNCTION;
|
||||
void vPortFreeStack( void *pv ) PRIVILEGED_FUNCTION;
|
||||
#else
|
||||
#define pvPortMallocStack pvPortMalloc
|
||||
#define vPortFreeStack vPortFree
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Setup the hardware ready for the scheduler to take control. This generally
|
||||
* sets up a tick interrupt and sets timers for the correct tick frequency.
|
||||
|
Reference in New Issue
Block a user