Dynamic xTaskCreate() doesn’t switch to spawned task with higher priority
I’m using FreeRTOS v10.0.0 on an ARM M3 and heap_4.c.
From InitTask() with priority 5 I call:
~~~
result = xTaskCreate(
GPIOBlinkTask, // task callback function
“BlinkTsk”, // task nickname
configMINIMALSTACK_SIZE, // stack size in words
NULL, // passed parameter
6, // task priority
NULL);
~~~
I expected that the call to xTaskCreate() would leave GPIO_BlinkTask() ready to run, and
therefore, FreeRTOS would switch to it, instead of retruning to InitTask(). I Looked through
xTaskCreate() and could not find any calls to the scheduler. This may or may not be a bug.
The FreeRTOSReferenceManual_v9.0.0 states: “Newly created tasks are initially placed in the Ready state, but will immediately become the Running state task if there are no higher priority tasks that are able to run.”
I expected that an RTOS will always have the highest task that is ready to run, running. Since
xTaskCreate() creates GPIO_BlinkTask() ready to run, why is it not immediately running?
I think I can solve this by calling vTaskDelay(0) just after xTaskCreate(GPIO_BlinkTask…)
Thanks,
Wayne
Dynamic xTaskCreate() doesn’t switch to spawned task with higher priority
Please forgive me. I rebuilt all my libraries and source code, and now it works. The FreeRTOSConfig.h files had the max priorites set below the levels I was using, so that the levels were clipped at max, and being equals, there was no task switch after the creation.
Sorry
I would remove this topic if I knew how.