[comp.lang.c] On coroutines in the C library

schwartz@gondor.cs.psu.edu (Scott Schwartz) (03/31/88)

In article <269@cantuar.UUCP> james@cantuar.UUCP (J. Collier) writes:
>   I agree with Peter's view that coroutines should be supported in the
>C library. As he says, coroutine packages are quite easy to write and they
>are indispensible for certain classes of application (I wanted one originally
>for a window server/multiplexor).

Agreed.

>   The current situation where everybody brews their own isn't really
>acceptable. The programs aren't portable, and the semantics differ
>sufficiently to make things confusing for the reader. The details will
>have to be thrashed out before a standard is defined.

According to a Sun release report, this sort of thing will be bundled
with SunOS 4.0.  Hey, that means it could end up in SysV! So we have
future prior art.  Is posix listening?

>   Pre-empting threads which share a common data space are probably not
>a good idea for most purposes - the synchronisation problems usually
>outweigh any advantages. 

Still, it would be nice to have preempting threads when you want them.
If your language supports monitors, you will have much less work to do
than if you just used semaphores.

I've never used modula, but I recently had some exposure to concurrent
euclid, which supports preemptive multitasking, shared variables and
monitors, and I liked how it all worked.  It would (will?) be a real
plus to have this functionality smoothly supported in C.

-- Scott Schwartz                       | Your array may be without head or     
        schwartz@gondor.cs.psu.edu      | tail, yet it will be proof against
                                        | defeat.  -- Sun Tzu, "The Art of War"