RTOSs (was Re: Teenagers ...)
2004-09-07 by Graham Davies
--- In AVR-Chat@yahoogroups.com, "Dave Hylands" <dhylands@b...> wrote: > ... 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. 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. 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. Graham.