Electronics > Beginners
RTOS vs Superloop, when to use?
(1/3) > >>
Muffins:
Hi Guys,

I have recently started down the train of learning about real time operating systems. I downloaded a port of ChibiOS to my arduino IDE and have been playing with that on an ATmege328p.

Anyway, I was wondering if superloops are actually used in consumer products and how I would determine if my program was reliable. In my mind RTOS is the way to go for making sure tasks play nice with one anther but at what point do I consider using it?
rstofer:
Superloops work well when there is no time critical task.  They can still be pretty responsive if you only test for one, or a few, conditions during each pass.  Don't get hung up in a subtask.  No while(1) loops... They are simple to code, simple to debug and don't hide all the details in semaphores.

If there are critical tasks that can't be handled by a simple interrupt driven queue, an RTOS is the way to go.  The thing is, most programs can work with simple IO queues.  There is still a need for interrupts but there isn't a need for a scheduler.

Finally, anybody can code a Superloop.  It's not quite as easy to write for an RTOS and debugging can be a nightmare.  Things firing off willy-nilly can sometimes have interesting inter-reactions.

Don't take sides!  There is a time and place for both approaches.  It really comes down to the system requirements and the skill of the programmer.

Windows and Linux are hybrids.  Neither are real-time.  I don't know much about Linux but Windows is a cooperative multitasking system where tasks willing give up their slot on some condition preemptive multitasking system.  Works well!
langwadt:

--- Quote from: rstofer on September 02, 2018, 09:36:05 pm ---Superloops work well when there is no time critical task.  They can still be pretty responsive if you only test for one, or a few, conditions during each pass.  Don't get hung up in a subtask.  No while(1) loops... They are simple to code, simple to debug and don't hide all the details in semaphores.

If there are critical tasks that can't be handled by a simple interrupt driven queue, an RTOS is the way to go.  The thing is, most programs can work with simple IO queues.  There is still a need for interrupts but there isn't a need for a scheduler.

Finally, anybody can code a Superloop.  It's not quite as easy to write for an RTOS and debugging can be a nightmare.  Things firing off willy-nilly can sometimes have interesting inter-reactions.

Don't take sides!  There is a time and place for both approaches.  It really comes down to the system requirements and the skill of the programmer.

Windows and Linux are hybrids.  Neither are real-time.  I don't know much about Linux but Windows is a cooperative multitasking system where tasks willing give up their slot on some condition.  Works well!

--- End quote ---

afaik Windows hasn't been cooperative multitasking since before win95

jmelson:

--- Quote from: rstofer on September 02, 2018, 09:36:05 pm ---
Windows and Linux are hybrids.  Neither are real-time.

--- End quote ---
Plain Linux is not real time, but there are several real time kernels that are built on Linux.  There are RTAI, Xenomai and RT-Preempt for the X86, and at least RT-Preempt for ARM.  Machinekit is a specialized RT system for CNC machine controllers, but it is a one-piece download that contains a complete Linux system with the RT-Preempt kernel for the BeagleBone Black.

Jon
rstofer:

--- Quote from: langwadt on September 02, 2018, 10:31:02 pm ---afaik Windows hasn't been cooperative multitasking since before win95

--- End quote ---

You are correct, they have changed to preemptive multitasking with the NT based kernels.

Navigation
Message Index
Next page
There was an error while thanking
Thanking...

Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod