On 2007-11-15, Chris Liechti <[email protected]> wrote:
> Grant Edwards schrieb:
>
>> Is anybody aware of a lightweight coroutine implementation for
>> mspgcc? The yield operation would need to be implemented
>> without disabling interrupts...
>
> i read the thread and see that prtothreads may be an option
> for you. what i have doesn't match the "not disabling
> interrupts" anyway. but i have done implementations of
> cooperative and preemptive multitasking for mspgcc.
>
> one of the tricks i used there is enabling interrupts only in
> one thread, so only one of the stacks needs to be large. i
> should at some point in time add these to the examples
> folder...
>
> however i'm not using them because the bytes used for multiple
> stacks without overflows are too precious and getting each
> stack depth as minimal as possible isn't always easy (and
> still wasting bytes).
That's a difficult problem. Even on parts with 8/16/32K or
more of RAM, I know of systems that are severely cramped
because they've got 6-8 tasks and each one has to have a
worst-case stack size.
> i often use the eventhandler that can be found in the mspgcc
> library (see examples/libraries/eventhandler)
>
> actually, if one must have interrupts at any time, that should
> be possible with my implementation. the stuff they put on the
> stack is taken away at the end of the interrupt so that is no
> problem even when switching, however, lowpower modes/wakeup
> may not work as expected and the stack depth may be unwanted.
My project actually has two modes: when it's awake it has to
handle interrupts at 4400Hz with very minimal interrupt
latency/skewing. The other mode is that it's asleep and doing
nothing until it gets an external interrupt. But once it's
been woken up, it disables all but the ciritical interrupts and
polls for all other events.
> in that case writing interrupt stubs in (inline) assembler
> that switch the stack call a (c) function and switch back the
> stack should not be too complicated.
I've started implimenting things with protothreads, and it
"feels right" if you know what I mean.
--
Grant Edwards grante Yow! World War Three can
at be averted by adherence
visi.com to a strictly enforced
dress code!