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

Continuations/coroutines in UNIX98 standard




James Knight writes:
>
> 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

I just did a little checking, and it turns out the Cygwin doesn't
support this interface -- at least, it lacks the swapcontext()
function. Some of the other Unix-on-Windows packages (like UWin or
MKS) have it, which presumably means it's not imposssible to
implement. Perhaps someone with a big Windows clue (Chris?) can
comment on similar interfaces over there?

-- 
Neel Krishnaswami
neelk@alum.mit.edu