mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-09 20:41:14 +00:00
change(freertos): Deprecate usage of vPortCleanUpTCB() by applications
Previously, if CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP was enabled, users would provide a definition for a vPortCleanUpTCB() hook function that is called right before a task's memory is freed in prvDeleteTCB(). However, vPortCleanUpTCB() will be reclaimed by ESP-IDF for internal use in v6.0. This commit introduces the following changes... Introduced a new CONFIG_FREERTOS_TASK_PRE_DELETION_HOOK option: - Provides the same pre-deletion hook functionality. But users now define vTaskPreDeletionHook() instead. - CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP still exists, but is marked as deprecated. This is to maintain compatibility with existing applications that already define vPortCleanUpTCB(). - Removed redundant --wl --wrap workaround with vPortCleanUpTCB() - Added todo notes to remove support for user defined vPortCleanUpTCB() completely in v6.0. - Updated test cases to use new CONFIG_FREERTOS_TASK_PRE_DELETION_HOOK option Freed up portCLEAN_UP_TCB() to call a new internal vPortTCBPreDeleteHook(): - vPortTCBPreDeleteHook() now replaces the previous "wrapped" implementation of vPortCleanUpTCB(). - vPortTCBPreDeleteHook() is an internal task pre-delete hook for IDF FreeRTOS ports to inject some pre-deletion operations. - Internal pre-delete hook now invokes user provided vTaskPreDeletionHook() if enabled. - Relocated vPortTCBPreDeleteHook() to correct section in port.c
This commit is contained in:
@@ -103,15 +103,6 @@ TEST_CASE("Test TLSP deletion callbacks", "[freertos]")
|
||||
//The variables pointed to by Thread Local Storage Pointer
|
||||
static uint32_t task_storage[portNUM_PROCESSORS][NO_OF_TLSP] = {0};
|
||||
|
||||
/* If static task cleanup is defined, can't set index 0 even if the calling task is not a pthread,
|
||||
as the cleanup is called for every task.
|
||||
*/
|
||||
#if defined(CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP)
|
||||
static const int skip_index = 0; /*PTHREAD_TLS_INDEX*/
|
||||
#else
|
||||
static const int skip_index = -1;
|
||||
#endif
|
||||
|
||||
static void del_cb(int index, void *ptr)
|
||||
{
|
||||
*((uint32_t *)ptr) = (TLSP_DEL_BASE << index); //Indicate deletion by setting task storage element to a unique value
|
||||
@@ -121,19 +112,11 @@ static void task_cb(void *arg)
|
||||
{
|
||||
int core = xPortGetCoreID();
|
||||
for(int i = 0; i < NO_OF_TLSP; i++){
|
||||
if (i == skip_index) {
|
||||
continue;
|
||||
}
|
||||
|
||||
task_storage[core][i] = (TLSP_SET_BASE << i); //Give each element of task_storage a unique number
|
||||
vTaskSetThreadLocalStoragePointerAndDelCallback(NULL, i, (void *)&task_storage[core][i], del_cb); //Set each TLSP to point to a task storage element
|
||||
}
|
||||
|
||||
for(int i = 0; i < NO_OF_TLSP; i++){
|
||||
if (i == skip_index) {
|
||||
continue;
|
||||
}
|
||||
|
||||
uint32_t * tlsp = (uint32_t *)pvTaskGetThreadLocalStoragePointer(NULL, i);
|
||||
TEST_ASSERT_EQUAL(*tlsp, (TLSP_SET_BASE << i)); //Check if TLSP points to the correct task storage element by checking unique value
|
||||
}
|
||||
@@ -151,9 +134,6 @@ TEST_CASE("Test FreeRTOS thread local storage pointers and del cb", "[freertos]"
|
||||
|
||||
for(int core = 0; core < portNUM_PROCESSORS; core++){
|
||||
for(int i = 0; i < NO_OF_TLSP; i++){
|
||||
if (i == skip_index) {
|
||||
continue;
|
||||
}
|
||||
TEST_ASSERT_EQUAL((TLSP_DEL_BASE << i), task_storage[core][i]); //Check del_cb ran by checking task storage for unique value
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user