1. 4
  1. 3

    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!

    1. 1

      As I recall, Contiki used this as well, with precisely the same footgun. They called their model protothreads.

    2. 1

      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.

      Stories with similar links:

      1. Coroutines in C via vletrmx 3 years ago | 19 points | 6 comments