[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Continuations/coroutines in UNIX98 standard



I also found this little tidbit here:
http://sources.redhat.com/ml/cygwin/1997-05/msg00610.html

I don't know what project that code is part of, but it appears to be 
implementing makecontext (which is really the only new thing that 
sigsetjmp/siglongjmp can't give you, I think) by manually frobbing the 
sp and pc fields of the sigjmp_buf in an architecture dependant manner 
such that when you call longjmp on the frobbed struct, it will run on a 
new stack and start running a new function.

James

On Sunday, October 6, 2002, at 10:26  PM, James Knight wrote:

> By complete accident I happened upon the documentation for 
> getcontext/setcontext/makecontext/swapcontext. It appears to be a 
> UNIX98 standard way of creating continuations in C. The only gotcha I 
> can find is that you need to allocate the alternate stacks yourself, 
> but that isn't too big a deal, as you should just be able to mmap some 
> memory to get it lazily allocated. Might be nifty to see whether it 
> works with/for GOO. I'm not sure how widely implemented it is but it 
> at least exists in linux and solaris.
>
> http://www.gnu.org/manual/glibc-2.2.3/html_chapter/libc_23.html
>
> james
>
>