At 07:14 PM 9/7/04 +0000, you wrote:
>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
I don't understand this assertion. The co-operative multitasking I've
worked with required a stack per task. A run-to-completion system wouldn't
and I can see that being described as a subset of co-operative multitasking
(or a superset of loop of loops for that matter).
Given a co-operative function to give up control called yield() and the
three tasks below I don't see how you could get away with a single
stack. Also feel free to visualize code around what's illustrated doing
all sorts of useful stuff and local variables taking up stack space ;)
taska()
{
taska_fn1();
taska_fn2();
taska_fn3();
}
taska_fn1()
{
yield();
}
taska_fn2()
{
yield();
taska_fn4();
yield();
}
taska_fn3()
{
yield();
}
taska_fn4()
{
yield();
}
taskb()
{
taskb_fn1();
taskb_fn2();
taskb_fn3();
}
taskb_fn1()
{
yield();
}
taskb_fn2()
{
yield();
taskb_fn4();
yield();
}
taskb_fn3()
{
yield();
}
taskb_fn4()
{
yield();
}
taskc()
{
taskc_fn1();
taskc_fn2();
taskc_fn3();
}
taskc_fn1()
{
yield();
}
taskc_fn2()
{
yield();
taskc_fn4();
yield();
}
taskc_fn3()
{
yield();
}
taskc_fn4()
{
yield();
}
>*** no special debugger awareness needed
Oh, I don't know I've seen debuggers get confused in co-op systems when the
stack switched. However, not having the task switch willy-nilly on you is
a great simplification.
>*** 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)
Again, I think it depends on the system. The synchronizing primitives just
don't need to protect against as much. For instance a pipe between two
cooperative tasks is quite useful. I've certainly seen error in a co-op
system where a structure should have been updated in an atomic fashion but
an implicit yield occurred due to an OS call that caused the stack to
switch to the consumer of the structure before the update was finished.
Robert
" 'Freedom' has no meaning of itself. There are always restrictions,
be they legal, genetic, or physical. If you don't believe me, try to
chew a radio signal. "
Kelvin Throop, IIIMessage
Re: [AVR-Chat] RTOSs (was Re: Teenagers ...)
2004-09-07 by Robert Adsett
Attachments
- No local attachments were found for this message.