I used this hack in a production embedded system which I’ve been maintaining for the past 7 years…
It was simpler and more performant than switching to an RTOS, but there’s definitely a bit of a footgun when writing new code - if you define new variables that have to survive a yield, you’d better remember to declare them static!
I used this hack in a production embedded system which I’ve been maintaining for the past 7 years…
It was simpler and more performant than switching to an RTOS, but there’s definitely a bit of a footgun when writing new code - if you define new variables that have to survive a yield, you’d better remember to declare them static!
As I recall, Contiki used this as well, with precisely the same footgun. They called their model protothreads.
I have been trialing this as an alternative to state machines…
Answer… if your state machine transition matrix is sparse… this results in much clearer and more understandable code.