Freertos-smp core with single core

Hi All,

We want to use freertos-smp kernel on single core also.
In prvYieldForTask() function there is an assert:
configASSERT( pxCurrentTCB->uxCriticalNesting > 0U );
I think that when working on single core this assert isn’t relevant and should be under
( configNUM_CORES > 1 ).
Please advise if I’m correct or not and if not what should I do when working with single core that there is no need to user Enter/Exit critical section?


Hi Hananya,

The design of FreeRTOS SMP considers about multiple running cores so prvYieldForTask must be called in critical section to provide mutual exclusion.

Can you provide more information about your purpose to run FreeRTOS-SMP on single core system?
If your system only has one core, it is suggested to run single core FreeRTOS on your system instead of FreeRTOS SMP. You can still run FreeRTOS SMP on single core system. However, the implementation is not exactly the same due to multiple cores consideration.


Thanks for your fast answer.
We’ve multiple demos one demo is with dual core while other demos are on single core.
We want to maintenance only one kernel that can work on both platforms.
If I’m not mistaken on single core there is no need to do it with Enter/Exit critical section.
Am I right?

Hi Hananya,

It is still required in single core system. The implementation of prvYieldForTask in FreeRTOS SMP accesses some of the shared data protected by critical section, like TCB and xYieldPendings. In single core system, running task can be interrupted by ISRs or preempted by another tasks. In that case, it is still possible that there will be shared data inconsistency due to race condition.

Hi Hananya,

Add more description here. prvYieldForTask is not required in single core FreeRTOS since there is only one choice. So I think you are suggesting that we don’t need the logic in prvYieldForTask when we are running FreeRTOS SMP with configNUM_CORES is 1.

We are working on merging the SMP branch into main branch. If configNUM_CORES is 1, it will run the single core FreeRTOS and prvYieldForTask is not used. If you are trying to use the SMP code on single core, would you please try the code from this branch. This is code that we are working on to bring the SMP feature to main branch.



Thanks for your answer.
What’s the stability level of this branch?
Do you have an open issues on this branch?


This is work in progress but fairly close to complete. We plan to merge it to main. The only reason we asked you to test is to ensure that the problem you pointed is addressed.