Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Thread

RE: [AVR-Chat] RTOSs (was Re: Teenagers ...)

RE: [AVR-Chat] RTOSs (was Re: Teenagers ...)

2004-09-07 by Dave Hylands

Hi Graham,

> > ... So, in an RTOS, the highest
> > priority ready-to-run thread
> > is always running...
> 
> This and the rest of your explanation applies to preemptive systems.

Yep - that's what I work in most of the time.

> As there seems to be no objection to the direction this discussion 
> thread is taking, perhaps I could state an opinion that preemption is 
> frequently overkill and people who have not already learned an RTOS 
> should consider cooperative systems.

I agree, especially when you're performing one dedicated thing (which is
what most 8-bit micros typically do). I brought up an RTOS just because
it's at the opposite end of the spectrum and typically "polling is bad"
when using an RTOS.

> Although the highest priority task cannot run until the currently 
> running task voluntarily gives up the CPU, this is often perfectly 
> acceptable. You just have to make sure all your tasks yield often 
> enough for the high priority tasks to meet their deadlines. You can 
> even use modified MRA to estimate schedulability.
> 
> The benefits of a cooperative system, such as ECROS, are:
> *** no need for a stack per task, i.e. more tasks in less RAM
> *** no special debugger awareness needed
> *** none of the hard-to-learn task synchronizing stuff like 
> semaphores, mutexes, critical sections, etc.
> *** no need to protect shared data structures (except those shared 
> with interrupts)
> 
> So, basically, you get something that is much easier to learn and use 
> and is, in many cases, just as good as a preemptive RTOS. If 
> something has to get done on a tight schedule, it's often possible to 
> do it in an interrupt. Anyway, a cooperative RTOS beats the heck out 
> of designing your own super-loop (unless you're really squeezed for 
> resources). I think many people who use a super-loop do so because a 
> preemptive RTOS is hard to learn to use safely and don't realize the 
> cooperative RTOS is a third possibility.

I'll agree with you on this point as well. I think the big issue with
working with an RTOS relates to synchronization. People forget that a
context switch can occur anyplace that an interrupt can occur. Having
controlled context switch locations can definitely make things easier.

--
Dave Hylands
Vancouver, BC, Canada
http://www.DaveHylands.com/

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.