Coroutines in C

Peter da Silva peter at ficc.uu.net
Wed Aug 16 03:00:21 AEST 1989


In article <563 at augean.OZ>, idall at augean.OZ (Ian Dall) writes:
> The scheme seems workable
> but portable implimentation is no doubt impossible

No, which is why the basic routines need to be standardised, at least to
the point where people implementing them on different compilers can agree
to the names and calling conventions.

> and it may not be possible
> to impliment at all on some machines.

True, but machines like that are likely to cause problems with varargs,
setjmp/longjmp, and so on as well.

> Would making the coroutine functions
> compiler "builtin" inline functions allow implimentation on a larger variety
> of machines?

Probably not. The difficulty is dealing with exotic stacks, not where the
code is done. As a thought experiment consider the case of making the
cocall from a subroutine of the coroutine... if inline code was needed
that would not be possible.

> What sort of problems do you want coroutines for? I seem to have survived about
> 14 years of programming without ever using them!

Mainly for the sort of event-loop programming endemic to windowing systems.
It would be easier to code this sort of application if minithreads were
available.
-- 
Peter da Silva, Xenix Support, Ferranti International Controls Corporation.
Business: peter at ficc.uu.net, +1 713 274 5180. | "The sentence I am now
Personal: peter at sugar.hackercorp.com.   `-_-' |  writing is the sentence
Quote: Have you hugged your wolf today?  'U`  |  you are now reading"



More information about the Comp.lang.c mailing list