mirror of
https://github.com/espressif/esp-idf.git
synced 2025-09-24 01:20:23 +00:00
freertos: prvCheckTasksWaitingTermination bugfix
Bugfix to prevent a self deleting no affinity task's memory from being freed by the idle task of the other core before the self deleting no affinity task is able to context switch out. prvCheckTasksWaitingTermination now checks if the task is still on pxCurrentTCB before freeing task memory.
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "esp_heap_caps.h"
|
||||
#include "rom/ets_sys.h"
|
||||
|
||||
#include "unity.h"
|
||||
|
||||
@@ -24,6 +25,8 @@
|
||||
#define DELAY_TICKS 2
|
||||
#define HEAP_CAPS (MALLOC_CAP_INTERNAL|MALLOC_CAP_DEFAULT)
|
||||
|
||||
#define DELAY_US_ITERATIONS 1000
|
||||
|
||||
|
||||
static void tsk_self_del(void *param)
|
||||
{
|
||||
@@ -35,6 +38,13 @@ static void tsk_extern_del(void *param)
|
||||
vTaskDelay(portMAX_DELAY); //Await external deletion
|
||||
}
|
||||
|
||||
static void tsk_self_del_us_delay(void *param)
|
||||
{
|
||||
uint32_t delay = (uint32_t)param;
|
||||
ets_delay_us(delay);
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
TEST_CASE("FreeRTOS Delete Tasks", "[freertos]")
|
||||
{
|
||||
/* -------------- Test vTaskDelete() on currently running tasks ----------------*/
|
||||
@@ -63,4 +73,11 @@ TEST_CASE("FreeRTOS Delete Tasks", "[freertos]")
|
||||
}
|
||||
TEST_ASSERT_EQUAL(before_heap, heap_caps_get_free_size(HEAP_CAPS));
|
||||
|
||||
/* Test self deleting no affinity task is not removed by idle task of other core before context switch */
|
||||
for(int i = 0; i < DELAY_US_ITERATIONS; i+= 10){
|
||||
vTaskDelay(1); //Sync to next tick interrupt
|
||||
xTaskCreatePinnedToCore(tsk_self_del_us_delay, "delay", 1024, (void *)i, UNITY_FREERTOS_PRIORITY - 1, NULL, tskNO_AFFINITY);
|
||||
ets_delay_us(10); //Busy wait to ensure no affinity task runs on opposite core
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user