May 11, 2013

Coroutines in C (bookmarks)

I downloaded Contiki for educational purposes, and first thing which got me trapped are protothreads. I have never read anything about coroutines (yes, blame on me not to read Donald Knuth's books - I'll get to those once I empty my bookshelf). 

Coroutines in C [chiark.greenend.org.uk/~sgtatham]
Excellent article to the point, with examples and explanations.

Coroutines in less than 20 lines of standard C [fanf.livejournal.com]
Tony Finch's coroutines which uses setjmp and longjmp for saving the state and jumping to new coroutine.

Protothreads [dunkels.com/adam/pt]
Main page for protothreads, if any questions, answer is there probably. Check examples there, or directly contiki implementation.