FreeRTOS / FreeRTOS-Kernel

FreeRTOS kernel files only, submoduled into https://github.com/FreeRTOS/FreeRTOS and various other repos.
https://www.FreeRTOS.org
MIT License
2.51k stars 1.05k forks source link

Will timer task be created twice for smp x2 freertos #1050

Closed fanghuaqi closed 1 month ago

fanghuaqi commented 1 month ago

According to the source code here https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/067d04e44e00f9970f43a44d3325f0c4e035523e/timers.c#L294-L301

When configNUMBER_OF_CORES = 1 and configUSE_CORE_AFFINITY = 0, it will go to above lines, and this xTimerCreateTimerTask function will be call in each cpu via vTaskStartScheduler called from main.

https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/067d04e44e00f9970f43a44d3325f0c4e035523e/tasks.c#L3665-L3690

But it seems it doesn't create different stack for different cpu's timer task like the idle task, is it made on intent?

Thanks

fanghuaqi commented 1 month ago

I checked other porting code, found that only main core need to execute main function, which including task creating and vTaskStartScheduler, other cores should only execute xPortStartScheduler and some other code to initialize required core interrupt controller.

https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/839ccb719b91ecd1cd066dc852110d2bbbe78cde/portable/ThirdParty/GCC/RP2040/port.c#L370-L391