View Single Post
Old 07-11-2012, 01:33 PM   #131
geekmaster
Carpe diem, c'est la vie.
geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.
 
geekmaster's Avatar
 
Posts: 6,433
Karma: 10773670
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
Piping is bad because multiprocessing has a relatively large overhead. That is why I am a fan of Simon Tatham's (brain damaging) coroutines, that are evolved from Duff's Device (which I also use a lot). Of course, assembler language stack swaps are better than coroutines, but not portable.

The piping is handy for initial testing (small evolutionary changes to existing code). Once it works, it can be refactored into a monolithic loop (perhaps using a state-machine if it gets too complicated). For monolithic loops that contain subfunctions that need to be performed at different rates, I use a DDA (digital differential algorithm) to do rate conversion to decide when to fire various periodic events.

For really slow primitive processors with tiny RAM but big ROM, I do all my timing with a huge jump table, and interleave all my periodic events evenly through it (dithered to prevent too many events firing on the same clock interrupt). I also do deferred non-maskable interrupt processing after saving the critical measurement. You know -- how to squeeze jaw-dropping performance out of tiny resources.

Last edited by geekmaster; 07-11-2012 at 01:40 PM.
geekmaster is offline   Reply With Quote