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). 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. 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.
chris