Close

Coroutines

A project log for PDP - Processor Design Principles

Distilling my experience and wisdom about the architecture, organisation and design choices of my CPUs

yann-guidon-ygdesYann Guidon / YGDES 08/28/2018 at 04:233 Comments

A discussion with an old-timer reminds me this coding technique for cooperative threads.

Coroutines are not used anymore because C and other languages don't allow this structure, so few people bother today... Yet they are still very interesting.

(more about them later)

...

Discussions

zpyerhnp wrote 12/27/2018 at 23:58 point

I thought coroutines were used a lot these days? I'm sure you've heard of goroutines, but also many up and coming languages have explicit support for them as an alternative to threads.


There are several C libraries implementing coroutines as well. They generally (ab)use the gcc label pointer extensions and/or setjmp.

  Are you sure? yes | no

Julian wrote 08/29/2018 at 19:35 point

"C and other languages don't allow this structure" ... well, there's always Simon Tatham's hack for implementing coroutines in C -- it's cheating a bit, because it doesn't *really* work the way you'd expect coroutines to work, but it emulates them quite nicely: https://www.chiark.greenend.org.uk/~sgtatham/coroutines.html

  Are you sure? yes | no

Yann Guidon / YGDES wrote 08/29/2018 at 23:38 point

Thanks ! I'll have to see that !

  Are you sure? yes | no