Porting two rtos

Could we put two rtos in single microcontroller.

When the microcontroller has multiple cores: yes that is possible. But on a single core, the 2 RTOS’s would have to share several common resources, which would make it difficult.
Beside that, FreeRTOS uses identifiers that can not be doubled so easily, like e.g. pxCurrentTCB.

So why do you have this question?

Thanks for your reply.
Well for sake of curiosity i just asked this question.
My understanding is porting two rtos in single core microcontroller is not possible.
But you have mentioned it is difficult, so is it really possible to port two rtos by any method.
And i m using stm32f7 microcontroller and freertos.
Freertos uses microcontrollers sys tick, pendsv, svc interrupt, and these we have to declare in freertos config.h, so when other rtos comes it also require these interrupt so don’t we get complication error when we build our code.
Thanks

The real fundamental difficulty is one of the primary functions of the RTOS is to decide what should be executing at a given moment in time. If you try to shoehorn to RTOSes into a single core, which one gets to choose if they differ.

It might be possible to make a sub-RTOS that acts like a task to the main RTOS, that when it gets scheduled, it decides which of its ‘sub-tasks’ get to run. Maybe the full RTOS is running pre-emptive, but the sub-RTOS is running a cooperative scheduler, so the tasks under it don’t need to worry as much about syncrony issues between themselves.

As for resources, the sys tick isn’t that hard to share (assuming they both want the same tick rate) as FreeRTOS basically just needs a subroutine call. The ponds and SVC interrupt are a more real issue, as you would need some way to tell which OS the interrupt was for, which I am not sure how you would do that for pendsv.

yes you are saying right.
but let say if we make a sub rtos to main rtos then i think it will not give any extra advantage because as we all know we could give two task same priority.

And as you mentioned about pendsv and SVC thats why i was thinking it might not be possible to port two RTOSes.

You have cleared many of my doubts. Thanks.