I wrote a simple test procedure: created a task, delayed, and then deleted the task, but the program got stuck.Here is code:
#include <stdio.h>
#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"
#include "cpu_hal.h"
void PrintTask3(void const *arg)
{
while (1) {
printf(" >[task] hello printTask! CoreId: %u\n", cpu_ll_get_core_id());
}
}
int TestTask3(void)
{
printf("TaskCreate...\n");
TaskHandle_t taskHandle = NULL;
if (xTaskCreate(PrintTask3, "test_task", 0x800/sizeof(StackType_t), NULL, 24, &taskHandle) != pdPASS)
{
printf("TaskCreate failedďź\n");
}
printf("CoreId: %u\n", cpu_ll_get_core_id());
vTaskDelay(100);
printf("TaskDelete...\n");
vTaskDelete(taskHandle);
printf("Delete finished...\n");
return 0;
}
Here is result:
TaskCreate...
CoreId: 1
>[task] hello printTask! CoreId: 0
>[task] hello printTask! CoreId: 0
>[task] hello printTask! CoreId: 0
>[task] hello printTask! CoreId: 0
>[task] hello printTask! CoreId: 0
>[task] hello printTask! CoreId: 0
>[task] hello printTask! CoreId: 0
>[task] hello printTask! CoreId: 0
>[task] hello printTask! CoreId: 0
>[task] hello printTask! CoreId: 0
>[task] hello printTask! CoreId: 0
>[task] hello printTask! CoreId: 0
>[task] hello printTask! CoreId: 0
>[task] hello printTask! CoreId: 0
>[task] hello printTask! CoreId: 0
>[task] hello printTask! CoreId: 0
>[task] hello printTask! CoreId: 0
>[task] hello printTask! CoreId: 0
>[task] hello printTask! CoreId: 0
>[task] hello printTask! CoreId: 0
>[task] hello printTask! CoreId: 0
>[task] hello printTask! CoreId: 0
>[task] hello printTask! CoreId: 0
>[task] hello printTask! CoreId: 0
>[task] hello printTask! CoreId: 0
>[task] hello printTask! CoreId: 0
>[task] hello printTask! CoreId: 0
>[task] hello printTask! CoreId: 0
>[task] hello printTask! CoreId: 0
>[task] hello printTask! CoreId: 0
>[task] hello printTask! CoreId: 0
TaskDelete...
The program did not execute âprintf(âDelete finishedâŚ\nâ);â. But everything works fine while debugging.