Some years ago I found a document by Simon Tatham with a coroutine.h source conaining a set C macros to make cooperative routines.
http://www.chiark.greenend.org.uk/~sgta ... tines.html
I became a fan of those macros that let you make a sort of multi tasking. No need to waste precious real time deterministic xcore threads to run low priority tasks.
Very smart the way Duff's device is used.
Also I suggest a reading at protothread:
http://dunkels.com/adam/pt/about.html
Coroutines: a "must know" for programmers (according to me)
- sethu_jangala
- XCore Expert
- Posts: 589
- Joined: Wed Feb 29, 2012 10:03 am
Thank you for sharing the information. Hopefully, the other members in the community also find the information useful.
Sethu.
Sethu.
These routines store all state globally, there can be only
one instance running consecutively; these aren't coroutines.
You could pass in a pointer to a struct to store the state in,
destroying all the neat syntactic sugar: but that does show
what you really have, namely an explicit state machine.
Don't the latest XC additions support cooperative threading
btw? I haven't more than glanced at it I'm afraid :-(
one instance running consecutively; these aren't coroutines.
You could pass in a pointer to a struct to store the state in,
destroying all the neat syntactic sugar: but that does show
what you really have, namely an explicit state machine.
Don't the latest XC additions support cooperative threading
btw? I haven't more than glanced at it I'm afraid :-(
Very interesting stuff Lele.
I think the XC addition segher mentioned is combinable functions. I haven't used that feature yet either, but it does sound similar to the information Lele linked to.
I think the XC addition segher mentioned is combinable functions. I haven't used that feature yet either, but it does sound similar to the information Lele linked to.
Segher is right: the first set of macro is not for reentrant/recursive functions.
But there is also a set which stores local variables
But there is also a set which stores local variables