Conversation

Replying to
Anything that crosses an SM_READ macro (the blocking call) is stored in a C struct. The rest goes on the C stack. This is ANF with constants bound to variables as well, to make implementation simpler. C compiler can take care of optimizing those away.
1
Started adding support for CSP rendezvous (csp.h in uc_tools, written in hard-to-use C macros). Added support for zero-copy mode. Eventually this needs to be fast (for the app: 137k int/sec on 72MHz CM3). Might need to specialize the scheduler further.
1
BTW doing this in Lua isn't all that bad. Of course refactoring is hard, but doable at this 1kloc complexity level. However manual let-insertion is annoying. Older Haskell code used a state-continuation monad for that, which is really convenient. Almost magic.
2
End of winter break. Experiment succeeded. Anything more complex needs better abstraction. Feeling a Racket itch coming up...
1
Going to have to specialize the CSP scheduler as well to make this fast. A bit more than a weekend project, but hey I'm learning things.
3
There is a lot of room to optimize things. One case that happens a lot is a task that only blocks on a single channel. This is just a co-routine and doesn't need to interact with any scheduler data structures.
1
Co-routines in my implementation would be just state pointer swap + (computed) goto. Not even a function call. Seems doable without turning it into a big production.
1
1
Restarted. Split the current compiler such that special forms that target the csp.c library are optional. Added coroutine call and yield functions as described. Probably best to first explore this without scheduler, then write specializable scheduler on top of coroutines.