Author Topic: Do you use a RTOS?  (Read 6156 times)

0 Members and 9 Guests are viewing this topic.

Offline alex_

  • Contributor
  • Posts: 29
  • Country: ch
Re: Do you use a RTOS?
« Reply #25 on: January 10, 2026, 11:04:27 pm »
Never. I am yet to find an issue that cannot be worked with good architecture, interrupts (you won't beat that latency) and a few status variables.
 
The following users thanked this post: uer166

Offline JPortici

  • Super Contributor
  • ***
  • Posts: 3912
  • Country: it
Re: Do you use a RTOS?
« Reply #26 on: January 11, 2026, 06:18:29 am »
I dabbled with freeRTOS a bit, but reverted almost all projects to be superloops using spare interrupts as threads

Could you elaborate on that a little?
Do you mean triggering them from elsewhere by setting interrupt flags manually?

Yes. The unused peripheral is never going to generate an interrupt, and if you can manually trigger it, voila. it's not at all something new (and we discussed it in a recent thread https://www.eevblog.com/forum/microcontrollers/general-patterns-to-talk-between-isr-contexts-or-isr-to-main-(cortex-m33stm32u5/25/ )
I really wish microcontrollers implemented software interrupts. The space is there, in all the unused vectors, it's just that you have no way to trigger them.

Never. I am yet to find an issue that cannot be worked with good architecture, interrupts (you won't beat that latency) and a few status variables.

Thir party libraries you must use as-is.
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 11182
  • Country: fi
Re: Do you use a RTOS?
« Reply #27 on: January 11, 2026, 06:52:48 am »
I really wish microcontrollers implemented software interrupts. The space is there, in all the unused vectors, it's just that you have no way to trigger them.

Um, NVIC->STIR?
 

Offline 5U4GB

  • Super Contributor
  • ***
  • Posts: 1735
  • Country: au
Re: Do you use a RTOS?
« Reply #28 on: January 11, 2026, 07:01:49 am »
Thanks!  Looks like it's mostly an incremental change, e.g. there's now an osThreadExit() in place of osThreadTerminate(osThreadGetId()), so only some minor changes required.

If you do run into any gotchas it'd be interesting to hear about them.
 

Offline cv007

  • Super Contributor
  • ***
  • Posts: 1061
Re: Do you use a RTOS?
« Reply #29 on: January 11, 2026, 07:13:32 am »
Quote
Yes. CMSIS-RTOS2
That seems to only describe an api layer on top of some actual os, so what is the os?
 
The following users thanked this post: newbrain

Offline betocool

  • Regular Contributor
  • *
  • Posts: 162
  • Country: au
Re: Do you use a RTOS?
« Reply #30 on: January 11, 2026, 09:13:46 am »
On STM32's I use FreeRTOS about 90% of the time unless it's a really simple thing. Haven't had issues yet. What I like about FreeRTOS is the ability to stream data from one process to another, at the expense of memory, of course. Other constructs like task notifications and such I also use a lot from ISRs.

I MUST use Zephyr for NRF52's at work. The RTOS concept of Zephyr is not too dissimilar from FreeRTOS (Queues, semaphores, streambuffers, pipes, etc) but I hate the several levels of abstraction between the software and the hardware, the Zephyr people use Device Tree Sources for their interfaces mostly. Fortunately they seem to work, for example SD cards, Bluetooth, etc, that all works fine if it's defined properly. However, woe if you have some minor issue, good luck finding where it is. It took me AGES to find out how to store data into flash memory. At least the folk at Nordic are very helpful with queries. Yeah, I avoid zephyr unless it's mandated by the IDE.

My 2c.

Cheers,

Alberto
 

Online peter-h

  • Super Contributor
  • ***
  • Posts: 6002
  • Country: gb
  • Doing electronics since the 1960s...
Re: Do you use a RTOS?
« Reply #31 on: January 11, 2026, 09:37:22 am »
That's funny... I have been using FreeRTOS without any drivers whatsoever. I didn't even know there might be any. I am interfacing to ADCs, DACs, SPI, SPI FLASH, ARINC429, etc, and wrote all that code.

As mentioned, a lot of code assumes it is running under an RTOS e.g. the ST-supplied USB and ETH stuff (both buggy as hell) needs it. I have no idea how one would structure that stuff without an RTOS.

Curiously, I never used the inter-task pipes. Never needed them. I just set up some global data in RAM and set a "data ready" flag. But I do use the mutexes a lot.
Z80 Z180 Z280 Z8 S8 8031 8051 H8/300 H8/500 80x86 90S1200 32F417
 

Offline woody

  • Frequent Contributor
  • **
  • Posts: 634
  • Country: nl
Re: Do you use a RTOS?
« Reply #32 on: January 11, 2026, 10:37:07 am »
No, I don't. I use superloops, interrupts and flags. Never saw the advantage of an RTOS, which probably says something about the complexity of the systems I design and/or my distaste of unnecessary overhead.
 

Offline gerbay

  • Regular Contributor
  • *
  • Posts: 88
  • Country: tr
Re: Do you use a RTOS?
« Reply #33 on: January 11, 2026, 10:44:14 am »
I really wish microcontrollers implemented software interrupts. The space is there, in all the unused vectors, it's just that you have no way to trigger them.

Um, NVIC->STIR?

ARM Cortex MCUs have a "Supervisor Call Instruction (SVC)" that can be used similarly to Intel x86 "real-mode" software interrupts. It works similarly to the "int" opcode in the x86 architecture. For example, "int 21h" (dos interrupt) causes a branch to the segment:offset at address 0x21*4 in the software interrupt table.

The SVC opcode can take 256 different parameter values ​​between [0..255], similar to the "int" opcode in x86.

You can examine how it works starting from page 31 of the following document:

https://www.eng.auburn.edu/~nelsovp/courses/elec5260_6260/slides/ARM%20STM32F476%20Interrupts.pdf
 

Offline Tation

  • Frequent Contributor
  • **
  • Posts: 311
  • Country: pt
Re: Do you use a RTOS?
« Reply #34 on: January 11, 2026, 02:24:01 pm »
If my memory serves me well, SVC can trigger a exception, but its service routine cannot directly access the parameter of the opcode, it must get the opcode using the PC in the stack, recover the opcode and decode it. Not too complex, but adds latency.
 

Offline gerbay

  • Regular Contributor
  • *
  • Posts: 88
  • Country: tr
Re: Do you use a RTOS?
« Reply #35 on: January 11, 2026, 02:40:12 pm »



What kind of latency and complexity do you think there might be here?
 

Offline gerbay

  • Regular Contributor
  • *
  • Posts: 88
  • Country: tr
Re: Do you use a RTOS?
« Reply #36 on: January 11, 2026, 02:45:31 pm »

ARM's RTX RTOS uses software interrupts for some functions. RTX performs much better than many other RTOSs. The source code for RTX is open; anyone can examine the code and see how it works.
 

Offline isometrik

  • Regular Contributor
  • *
  • Posts: 80
  • Country: ca
Re: Do you use a RTOS?
« Reply #37 on: January 11, 2026, 03:29:28 pm »
Quote
Yes. CMSIS-RTOS2
That seems to only describe an api layer on top of some actual os, so what is the os?

You are right. But that's the beauty of it, as it makes your source code more portable.

I am currently using Arm's Keil MDK-ARM IDE, so the abstracted/underlying RTOS is Keil's RTX5.

Having glanced at STMicroelectronics' CubeMX/CubeIDE, it nowadays support the CMSIS-RTOS2 API, but use FreeRTOS.
 

Online peter-h

  • Super Contributor
  • ***
  • Posts: 6002
  • Country: gb
  • Doing electronics since the 1960s...
Re: Do you use a RTOS?
« Reply #38 on: January 11, 2026, 07:28:44 pm »
Quote
ARM's RTX RTOS uses software interrupts for some functions. RTX performs much better than many other RTOSs.

AFAICT, at 168MHz the overhead of FreeRTOS is somewhere south of negligible.

I have traced the context switch code at times and it is very short.

Mutexes are slower but at around 1-2us still fine for where one might use them.
Z80 Z180 Z280 Z8 S8 8031 8051 H8/300 H8/500 80x86 90S1200 32F417
 

Offline JPortici

  • Super Contributor
  • ***
  • Posts: 3912
  • Country: it
Re: Do you use a RTOS?
« Reply #39 on: January 11, 2026, 09:02:43 pm »
I really wish microcontrollers implemented software interrupts. The space is there, in all the unused vectors, it's just that you have no way to trigger them.

Um, NVIC->STIR?

there are architectures other than ARM.
 

Offline alex_

  • Contributor
  • Posts: 29
  • Country: ch
Re: Do you use a RTOS?
« Reply #40 on: January 13, 2026, 12:02:19 am »
Thir party libraries you must use as-is.

Which ones need RTOS? I am curious

If I need an external library I generally trim it and optimize the HAL as it is usually very low performance and my devices require power optimization, I am not going to wait forever for a few bytes to be pushed to an SPI.
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 11182
  • Country: fi
Re: Do you use a RTOS?
« Reply #41 on: January 13, 2026, 06:59:06 am »
I really wish microcontrollers implemented software interrupts. The space is there, in all the unused vectors, it's just that you have no way to trigger them.

Um, NVIC->STIR?

there are architectures other than ARM.

Sure, I just misunderstood "I really wish microcontrollers implemented software interrupts" as a claim that microcontrollers generally do not, and that was weird, because most popular microcontrollers of past 10 years do.
 

Offline JPortici

  • Super Contributor
  • ***
  • Posts: 3912
  • Country: it
Re: Do you use a RTOS?
« Reply #42 on: January 13, 2026, 07:23:27 am »
Thir party libraries you must use as-is.

Which ones need RTOS? I am curious

If I need an external library I generally trim it and optimize the HAL as it is usually very low performance and my devices require power optimization, I am not going to wait forever for a few bytes to be pushed to an SPI.

most radio microcontrollers now provide their stack as a binary blobs sthat expects freeRTOS or Zephir

Sure, I just misunderstood "I really wish microcontrollers implemented software interrupts" as a claim that microcontrollers generally do not, and that was weird, because most popular microcontrollers of past 10 years do.

Sorry, i lost a "most" along the way
« Last Edit: January 13, 2026, 07:26:08 am by JPortici »
 

Online peter-h

  • Super Contributor
  • ***
  • Posts: 6002
  • Country: gb
  • Doing electronics since the 1960s...
Re: Do you use a RTOS?
« Reply #43 on: January 13, 2026, 02:47:46 pm »
What is the use of a software interrupts?

I remember the DOS INT21 and others, from my 80x86 asm days, but what is the point in an embedded system where you just call a function?
Z80 Z180 Z280 Z8 S8 8031 8051 H8/300 H8/500 80x86 90S1200 32F417
 

Offline gerbay

  • Regular Contributor
  • *
  • Posts: 88
  • Country: tr
Re: Do you use a RTOS?
« Reply #44 on: January 13, 2026, 02:58:47 pm »
What is the use of a software interrupts?

I remember the DOS INT21 and others, from my 80x86 asm days, but what is the point in an embedded system where you just call a function?

https://www.iotality.com/armcm-svc/
 

Offline eutectique

  • Frequent Contributor
  • **
  • Posts: 632
  • Country: be
Re: Do you use a RTOS?
« Reply #45 on: January 13, 2026, 03:25:15 pm »
What is the use of a software interrupts?

For example, Nordic Semi uses them as an API to SoftDevices. Proprietary Bluetooth code occupies lower part of flash, the user code is placed above it by the linker.

At boot, SoftDevice starts first, redirects the interrup vectors, adds pointers to its SVC handlers and then jumps into user's main().

Then, the application calls Bluetooth library functions which are essentially SVC calls.
 

Offline JPortici

  • Super Contributor
  • ***
  • Posts: 3912
  • Country: it
Re: Do you use a RTOS?
« Reply #46 on: January 13, 2026, 03:26:12 pm »
What is the use of a software interrupts?

what is the use of interrupts?
 

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 23122
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: Do you use a RTOS?
« Reply #47 on: January 13, 2026, 03:36:28 pm »
What is the use of a software interrupts?

what is the use of interrupts?

You're beginning to sound like me  ;D

More seriously, there is a lot to be gained from integrating software and hardware concepts both conceptually and physically. That's true "all the way" from embedded systems to server and HPC systems.
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
 

Online peter-h

  • Super Contributor
  • ***
  • Posts: 6002
  • Country: gb
  • Doing electronics since the 1960s...
Re: Do you use a RTOS?
« Reply #48 on: January 13, 2026, 03:43:26 pm »
I can see the use of them if you are supplied a binary library, like MS-DOS, which cannot be linked to anything. Then you have to call fixed address[es] to access the function(s).
Z80 Z180 Z280 Z8 S8 8031 8051 H8/300 H8/500 80x86 90S1200 32F417
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 11182
  • Country: fi
Re: Do you use a RTOS?
« Reply #49 on: January 13, 2026, 04:17:26 pm »
What is the use of a software interrupts?

I use them extensively to continue processing at lower priority. Typical conceptual example:

Code: [Select]
UART_handler()
{
     p_collect[i++] = RXDR;
     if(finished_condition (e.g. enough bytes))
     {
           SWAP(p_collect, p_process);
           SW_IRQ(processing_handler); // Actual function will not run instantly, but tail-chain and run after this function returns because it has lower priority than this function
     }
}

processing_handler()
{
     // Do whatever with *p_process - you have time until the next finished_condition
     // UART_handler() can run many times and will pre-empt this handler because it has higher priority - this function doesn't need to care, it writes to *p_collect
}

So, something to trigger from a condition which is more complex than what peripherals can generate on their own. (In the world of perfectly configurable DMAs etc. we would not need the above example, but could use a single interrupt equivalent to the "processing_handler" but triggered directly from the perfect peripheral.)
« Last Edit: January 13, 2026, 04:21:30 pm by Siwastaja »
 
The following users thanked this post: newbrain, JPortici


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf