Author Topic: How does one select an RTOS ?  (Read 18805 times)

0 Members and 1 Guest are viewing this topic.

Offline metebalciTopic starter

  • Frequent Contributor
  • **
  • Posts: 460
  • Country: ch
How does one select an RTOS ?
« on: December 04, 2023, 05:34:10 pm »
I wonder the major factors that are important for selecting an RTOS. I am asking only for Cortex-M and similar level MCUs and considering only the ones with open source/free licenses but feel free to mention commercial ones. To have a more concrete question, I can ask, why/when should I not choose FreeRTOS, and why/when should I use X (mbed, rtx, apache projects, embOS, threadx etc.) ?
 

Offline uer166

  • Super Contributor
  • ***
  • Posts: 1285
  • Country: us
Re: How does one select an RTOS ?
« Reply #1 on: December 05, 2023, 05:08:49 am »
What is your application? More often than not an RTOS is not required, and it's overused "just because". That can end up as a very suboptimal choice for a project.
 
The following users thanked this post: Siwastaja

Offline JPortici

  • Super Contributor
  • ***
  • Posts: 3927
  • Country: it
Re: How does one select an RTOS ?
« Reply #2 on: December 05, 2023, 05:51:24 am »
I only used FreeRTOS, because it is the only RTOS that provided example projects for my architecture of choice, that i could use to verify it was actually working there. Also the only one that provided some RTOS debugging tools that talks with my IDE/Debugger (a state viewer, number of tasks, queue, timers and their status, memory occupied and address. Not much but that helped me debug a ton of things i couldn't have done otherwise, unless i would search variable by variable for the same information. And the OS's statistic functions are basically useless once a stack has overflown)

I wouldn't mind trying something else to see if i like it better (ucos, or threadx/zephir as both seem to be all the rage for anything connected these days) but it needs the above for me to really consider it
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 17876
  • Country: fr
Re: How does one select an RTOS ?
« Reply #3 on: December 05, 2023, 06:06:21 am »
FreeRTOS is the default choice indeed, it's relatively lightweight, well known and there's nothing much bad about it.

I have used uC/OS in the past, but back when it was at an earlier version, and it required a commercial license. I don't know exactly how it stands now in terms of licensing. The source code is released with an Apache 2.0 license, but I don't know if they still have a commercial licensing scheme for commercial applications, something to check. The source code is there: https://github.com/weston-embedded/uC-OS3
It's usually better regarded for "safety-critical" applications than FreeRTOS. Again, haven't had a look at it in a while. But I'd say it's an alternative worth a look.

I would personally not touch ThreadX. Zephyr looks interesting, but much heavier than the two above and with a steeper learning curve.

Of course, not everything requires an RTOS, so that's the first thing to settle before picking one.
 
The following users thanked this post: 5U4GB

Offline eleguy

  • Regular Contributor
  • *
  • Posts: 158
  • Country: fi
Re: How does one select an RTOS ?
« Reply #4 on: December 05, 2023, 06:31:14 am »
We use Zephyr but as said above the learning curve is worse than a right angle and documentation is more than often in a miserable state when you actually need it. BUT, once you get something working which happens typically with the help of crawling source files and breaking out zillion undocumented macros it works for good. Maybe as a Linux guy I am bit biased to say but the Zephyr comes for example with the shell built in which is pretty cool and extendable.

https://docs.zephyrproject.org/latest/services/shell/index.html

I don't see reasons why one should not select FreeRTOS. I have used it as well (with ESP-IDF) and found it much more easy to approach than the Zephyr. However, I am not sure if it is fair to compare those two as is. The FreeRTOS is closer to the bare metal and the Zephyr towards the Linux world.
« Last Edit: December 05, 2023, 07:21:53 am by eleguy »
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4676
  • Country: us
Re: How does one select an RTOS ?
« Reply #5 on: December 05, 2023, 07:05:24 am »
Quote
I wonder the major factors that are important for selecting an RTOS. I am asking only for Cortex-M and similar level MCUs
If I were to select a "commercial" (or at least externally developed) RTOS, an important thing I would look for is portability to all the chips I'd be likely to use.  That may sound simple, but it immediately disqualifies vendor-specific things like TI-RTOS.  MBED-OS similarly does not seem to have much support for Atmel/Microchip CPUs (or any non-ARM architectures?)  Similarly, do the chip vendors support the OS, or is it all from 3rd parties?


Second is whether it supports peripheral "stacks" that I'm not interested in writing myself.  USB?  TCP/IP?  Wireless protocols?  (Vendor-proprietary wireless protocols, ie ROM or "required" SDKs.)  Multi-core scheduling?  Security features?


Third is support and reputation of the OS and stacks...

 

Offline eleguy

  • Regular Contributor
  • *
  • Posts: 158
  • Country: fi
Re: How does one select an RTOS ?
« Reply #6 on: December 05, 2023, 07:35:03 am »
Quote
I wonder the major factors that are important for selecting an RTOS. I am asking only for Cortex-M and similar level MCUs
If I were to select a "commercial" (or at least externally developed) RTOS, an important thing I would look for is portability to all the chips I'd be likely to use.  That may sound simple, but it immediately disqualifies vendor-specific things like TI-RTOS.

This is the main reason why we selected Zephyr in the past. It did sound very tempting to have something "portable" in our hands. I just wanted to say that it does not come for free. It is possible unlike in the many vendor specific solutions but one really has to have a need for that. Pretty easily you are the one who is then writing implementation for the selected MCU. It is good to check (often misleading) Zephyr "supported list" page and notice at how "lightly" or well something is actually supported. Sometimes you find only very basic things like GPIO and UART in the list.
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 11497
  • Country: fi
Re: How does one select an RTOS ?
« Reply #7 on: December 05, 2023, 07:48:30 am »
Often the reason for any particular choice would be, "others made the choice". Maybe you want to use manufacturer example projects, and they use, say, Zephyr. I don't think anyone in their right mind would voluntarily choose Zephyr for a project they make from scratch with no such constraints.

I usually do not use an RTOS at all, but have had no problems adapting into projects which use FreeRTOS; it's quite simple and does not force a completely different thinking pattern on parallelism; for example you can still write interrupt handlers.
« Last Edit: December 05, 2023, 10:34:58 am by Siwastaja »
 

Offline metebalciTopic starter

  • Frequent Contributor
  • **
  • Posts: 460
  • Country: ch
Re: How does one select an RTOS ?
« Reply #8 on: December 05, 2023, 08:11:10 am »

Thanks for the replies, really very helpful.

I think I do not know the RTOS market share, who are the lets say top 3 or 5 and covering how much of the market ? Again, maybe I should say I am interested about not too small MCUs (definitely not smaller than Cortex-M0) and not large chips (definitely not bigger than the largest Cortex-M).

Also, nobody mentioned embOS or Keil RTX, is it because they are commercial or they are not popular ?

 

Offline shtirka

  • Contributor
  • Posts: 27
  • Country: se
Re: How does one select an RTOS ?
« Reply #9 on: December 05, 2023, 08:31:23 am »
I wonder the major factors that are important for selecting an RTOS. I am asking only for Cortex-M and similar level MCUs and considering only the ones with open source/free licenses but feel free to mention commercial ones. To have a more concrete question, I can ask, why/when should I not choose FreeRTOS, and why/when should I use X (mbed, rtx, apache projects, embOS, threadx etc.) ?

Hello,
There are several factors that I usually use when choosing an RTOS for any of my projects (no matter if its open source or commercial):

- RTOS ecosystem and support - how much support is there for an RTOS from the various tools like compilers and how easy is it to get the support from the original authors?
- RTOS licensing model
- RTOS source code distribution and modification constrains?
- Does the RTOS need to be certified for a specific industry or application?
- Performance?
- Features?
- Additional middleware components?
- How labour intensive is it to integrate with current project?
- Cost?
- Will it make my life easier to solve a specific problem?
- Is there a requirement for a minimum "effective throughput" that an RTOS can deliver (in comparison to other solutions)?

Hope that helps you to get started

Ilya 
 
The following users thanked this post: 5U4GB

Offline fchk

  • Frequent Contributor
  • **
  • Posts: 430
  • Country: de
Re: How does one select an RTOS ?
« Reply #10 on: December 05, 2023, 08:45:11 am »
I had to choose an RTOS, and I ended up with NuttX.

I wanted/needed a complete package with not only the kernel but also stacks and drivers for Ethernet and TCP/IP and USB, and I absolutely didn't want to mix and match products from different vendors for support reasons. This eliminated FreeRTOS, which in itself is only the kernel.

 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4676
  • Country: us
Re: How does one select an RTOS ?
« Reply #11 on: December 05, 2023, 08:45:21 am »


Quote
"other's made the choice"


Ah yes.  One of the reasons that environments like Arduino are so important is that vendors need to catch engineers when they're "Playing."
Because the number of times a company will delay for a couple of months while their engineers "evaluate" competitive architectures or chip families is ... very small.  Most of the time you get stuck with "something compatible with the last thing we used" (which is much better than "something a sharp salescritter sold to middle management.")
 

Offline Berni

  • Super Contributor
  • ***
  • Posts: 5449
  • Country: si
Re: How does one select an RTOS ?
« Reply #12 on: December 05, 2023, 09:07:20 am »
Most often the best RTOS choice is none.

You can do plenty of simple multitasking in a more efficient way using plain C with hot loops, state machines, interrupts..etc. So you don't want to get too comfortable with an RTOS where every problem starts to look like a 'multithreaded nail'.

But there are some more complex applications where it does indeed make sense to have a RTOS where the simultaneous functionality is too complex to reduce down to functions that return in reasonable amounts of time. For that i like to use FreeRTOS because it is fairly simple as far as an RTOS goes while giving plenty of features and good support for pretty much any platform you would want to use.
 

Offline AVI-crak

  • Regular Contributor
  • *
  • Posts: 152
  • Country: ru
    • Rtos
Re: How does one select an RTOS ?
« Reply #13 on: December 05, 2023, 09:33:31 am »
Everyone should write their own OS, if only as an experiment.
 

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 23122
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: How does one select an RTOS ?
« Reply #14 on: December 05, 2023, 09:53:36 am »
Most often the best RTOS choice is none.

You can do plenty of simple multitasking in a more efficient way using plain C with hot loops, state machines, interrupts..etc. So you don't want to get too comfortable with an RTOS where every problem starts to look like a 'multithreaded nail'.

Agreed, but I would expand "multithreaded nail" to "pretending to be a simple linear flow of control but introducing different problems nail"  >:D
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline metebalciTopic starter

  • Frequent Contributor
  • **
  • Posts: 460
  • Country: ch
Re: How does one select an RTOS ?
« Reply #15 on: December 05, 2023, 11:16:37 am »

I think I should have said this from the beginning, that I do not have an application in mind asking this question and I am aware RTOS might be unnecessary.

A few people mentioned the peripheral support/stacks, which I had also in my mind. Not all, but I looked at some RTOSs, and it seems some of the peripherals are usually supported like network, but for example USB is not.
 

Offline shtirka

  • Contributor
  • Posts: 27
  • Country: se
Re: How does one select an RTOS ?
« Reply #16 on: December 05, 2023, 11:55:32 am »

I think I should have said this from the beginning, that I do not have an application in mind asking this question and I am aware RTOS might be unnecessary.

A few people mentioned the peripheral support/stacks, which I had also in my mind. Not all, but I looked at some RTOSs, and it seems some of the peripherals are usually supported like network, but for example USB is not.

As far as I am personally aware, Apache's NuttX is one of the very few RTOSes (QNX is another example - but it is a closed source and commercial RTOS) out there where you also get inbuilt support for a variety of hardware and stacks, and not just a "naked" kernel.
I will be speaking from my personal experience here (others may have other views on the matter), but generally speaking an RTOS is a tool you just dont use on a whim because there's only a very limited number of use cases where it truly shines (like when you need a highly deterministic system behaviour, or when you have strict demands on system performance or effective/maximum throughput) so using an RTOS will normally cause you more grief than it's worth (because usually it takes more effort to develop a solution to a problem or the solution becomes more complex than it needs to be - and also the system becomes more difficult to support in the long run). I would suggest you revisit my earlier message on how I would approach choosing an RTOS - at least as a starting point since your initial question on how to choose an RTOS was a bit theoretical and quite often a choice of an RTOS (or whether it should even be chosen as a tool to begin with since there might be an alternative way to solve a problem) would be very contextual for your project/team/organisation needs.

Ilya
 

Offline JPortici

  • Super Contributor
  • ***
  • Posts: 3927
  • Country: it
Re: How does one select an RTOS ?
« Reply #17 on: December 05, 2023, 12:30:07 pm »

I think I should have said this from the beginning, that I do not have an application in mind asking this question and I am aware RTOS might be unnecessary.

A few people mentioned the peripheral support/stacks, which I had also in my mind. Not all, but I looked at some RTOSs, and it seems some of the peripherals are usually supported like network, but for example USB is not.

Well, USB is still pretty low level and it's usually easy to adapt the existing vendor stack to whatever RTOS. This is because you either process everything in a loop (and the loop just becomes a thread) or using interrupts and the whole thing is self contained. The most the RTOS has to do is manage the queues that exchange data from/to the endpoints

IMHO you should just pick one that's supported by whatever hardware you have in front of you right now, compile the example project and see the LED blink.
Of course there is MUCH MORE in writing a firmware using whatever RTOS than just knowing the API, but luckily major firmware offers also provide books to learn generic RTOS concepts alongside with examples (i like the RTOS and uC/OS ones)
« Last Edit: December 05, 2023, 12:32:27 pm by JPortici »
 

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 23122
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: How does one select an RTOS ?
« Reply #18 on: December 05, 2023, 12:31:00 pm »
... because there's only a very limited number of use cases where [RTOA] truly shines (like when you need a highly deterministic system behaviour, or when you have strict demands on system performance or effective/maximum throughput) so using an RTOS will normally cause you more grief than it's worth (because usually it takes more effort to develop a solution to a problem or the solution becomes more complex than it needs to be - and also the system becomes more difficult to support in the long run).

I don't disagree, but I will highlight that if you need "highly deterministic system behaviour" and "strict demands on system performance" then you need to look at much more than the RTOS.

The best overall solutions I have seen for hard realtime performance guarantees are FPGAs and XMOS' xCORE processors running xC. The RTOS is, to all intents and purposes, implemented in hardware, the IDE tells you the min/max code execution times (none of this "measure and hope you have bumbled across the worst performance" rubbish!), USB and Ethernet libraries, 4000MIPS MCUs, buy them at DigiKey.

Example of hard realtime capabilities: software captures/generates 100MB/ Ethernet bitstreams or USB comms, performance guaranteed while the processor is also doing all the interesting things with hard realtime guarantees :)

Naturally, as will all technologies, there are swings and roundabouts. I have found the devices fun and easy to program with no late surprises due to, say, errata sheets. I had my first capture+process+USB comms to PC application running within a day of receiving the boards.
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline metebalciTopic starter

  • Frequent Contributor
  • **
  • Posts: 460
  • Country: ch
Re: How does one select an RTOS ?
« Reply #19 on: December 05, 2023, 12:51:46 pm »

I think I should have said this from the beginning, that I do not have an application in mind asking this question and I am aware RTOS might be unnecessary.

A few people mentioned the peripheral support/stacks, which I had also in my mind. Not all, but I looked at some RTOSs, and it seems some of the peripherals are usually supported like network, but for example USB is not.

As far as I am personally aware, Apache's NuttX is one of the very few RTOSes (QNX is another example - but it is a closed source and commercial RTOS) out there where you also get inbuilt support for a variety of hardware and stacks, and not just a "naked" kernel.
I will be speaking from my personal experience here (others may have other views on the matter), but generally speaking an RTOS is a tool you just dont use on a whim because there's only a very limited number of use cases where it truly shines (like when you need a highly deterministic system behaviour, or when you have strict demands on system performance or effective/maximum throughput) so using an RTOS will normally cause you more grief than it's worth (because usually it takes more effort to develop a solution to a problem or the solution becomes more complex than it needs to be - and also the system becomes more difficult to support in the long run). I would suggest you revisit my earlier message on how I would approach choosing an RTOS - at least as a starting point since your initial question on how to choose an RTOS was a bit theoretical and quite often a choice of an RTOS (or whether it should even be chosen as a tool to begin with since there might be an alternative way to solve a problem) would be very contextual for your project/team/organisation needs.

Ilya

Thanks Ilya, great feedback.
 

Offline metebalciTopic starter

  • Frequent Contributor
  • **
  • Posts: 460
  • Country: ch
Re: How does one select an RTOS ?
« Reply #20 on: December 05, 2023, 01:12:57 pm »
Well, USB is still pretty low level and it's usually easy to adapt the existing vendor stack to whatever RTOS. This is because you either process everything in a loop (and the loop just becomes a thread) or using interrupts and the whole thing is self contained. The most the RTOS has to do is manage the queues that exchange data from/to the endpoints

Maybe. I dont know what the USB stack in an RTOS provides, it might be easier to use.

IMHO you should just pick one that's supported by whatever hardware you have in front of you right now, compile the example project and see the LED blink.

That is what I am doing at the moment, which made me question why I picked this one (FreeRTOS), hence the question.
 

Offline metebalciTopic starter

  • Frequent Contributor
  • **
  • Posts: 460
  • Country: ch
Re: How does one select an RTOS ?
« Reply #21 on: December 05, 2023, 01:18:49 pm »
If I were to select a "commercial" (or at least externally developed) RTOS, an important thing I would look for is portability to all the chips I'd be likely to use.  That may sound simple, but it immediately disqualifies vendor-specific things like TI-RTOS.  MBED-OS similarly does not seem to have much support for Atmel/Microchip CPUs (or any non-ARM architectures?)  Similarly, do the chip vendors support the OS, or is it all from 3rd parties?

Not directly related to my question but is it common to make such a big change (change the architecture) during the lifetime of a normal product ?
 

Offline 5U4GB

  • Super Contributor
  • ***
  • Posts: 1830
  • Country: au
Re: How does one select an RTOS ?
« Reply #22 on: December 05, 2023, 01:29:12 pm »
Another comment specifically on the commercial-RTOS side, VxWorks for example is big and bloated and expensive but like Windows it's the 800-pound-gorilla that everything has to learn to play with, meaning that (almost) every bit of hardware and (almost) every device vendor has support with/for it.  With open-source/volunteerish projects OTOH you either hope someone else has written the drivers you need and they're still current and maintained, or write them yourself.  So it really depends on whether it's a small-scale/cheap/personal-project thing or a large-scale/heavy-duty commercial thing.
 

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 23122
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: How does one select an RTOS ?
« Reply #23 on: December 05, 2023, 01:37:42 pm »
Maybe. I dont know what the USB stack in an RTOS provides, it might be easier to use.

Well, in the XMOS ecosystem it provides an interface to a PC and/or IDE.

Thus development: debugging, single stepping, peek/poke, etc. Deliverables: any GUI/logging you want your application to have on the PC. And all without disturbing the guaranteed timing of the hard realtime parts of your code. That's the wonder of multi-core MCUs :)

Whether that is a benefit for you is for you to assess :)
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline gpr

  • Contributor
  • Posts: 43
  • Country: gb
Re: How does one select an RTOS ?
« Reply #24 on: December 05, 2023, 01:57:45 pm »
Most often the best RTOS choice is none.

You can do plenty of simple multitasking in a more efficient way using plain C with hot loops, state machines, interrupts..etc.
Sounds good for a simple hobby projects or as a learning experience. Or if you have very limited resources and trying to save a few kb of memory.

In practice, implementing your own multitasking tends to become a chunk of spaghetti with subtle bugs and hacks, especially with multiple developers.
 
The following users thanked this post: 5U4GB


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

- - -
-->