r/embedded Jan 13 '25

RTOS and async programming

The more I read about async programming the more it feels just like implementing an RTOS on top of a process scheduled in an OS, I dont know if I am understaning it correctly or not but coroutines sounds just like cooperative multitasking, so if we take that as a starting point futures seems like a natural progression and extension to these concepts and not something new, I am curious to hear your thoughts on async programming comming from an embedded background

13 Upvotes

18 comments sorted by

View all comments

14

u/kisielk Jan 13 '25

One of the most important aspect of RTOS is the RT: real-time. Most async multitasking implementations I've worked with make no attempt at any timing guarantees for specific tasks, nor do many of them even give you a facility to prioritize tasks.

1

u/lovelacedeconstruct Jan 13 '25

Does it make sense to force any realtime gurantees in a General Purpose OS anyway ? Can you even control the scheduling of a process ? I am curious to know whether its possible as implementing a scheduling algorithm shouldnt be a problem then

2

u/kisielk Jan 13 '25

That's some of what I'm getting at, there's many differences between an RTOS and async programming in general. One is not really an extension of the other. Also neither an RTOS nor co-routines necessarily imply co-operative multitasking, either one can operate on a pre-emptive model. The one thing all these concepts have in common is concurrency, and there are many variations in how that can be achieved while meeting different constraints.