getcontext

Timo Teräs timo.teras at iki.fi
Thu Mar 17 04:40:44 UTC 2011


On 03/17/2011 01:06 AM, Rich Felker wrote:
> On Wed, Mar 16, 2011 at 09:16:48PM +0100, Joakim Tjernlund wrote:
>> Impl. of portable CoRoutines, http://en.wikipedia.org/wiki/Coroutine ,
>> likes to use get/setcontext. Don't think there is anything else these
>> can use.
> 
> Coroutines can be implemented portably on top of pthreads and
> condition variables, barriers, or semaphores.

But that's making the coroutines pointless. Their idea is to be light
weight. And you can achieve that only with get/setcontext. We'll one
could do setjmp hacks too. Or write one's own context changing things in
assembler.

But those are useful still today. E.g. the new Google Go language has
coroutines built-in into it. The language runtime implements them with
native assembler.


More information about the uClibc mailing list