[gclist] Re: gclist-digest V3 #84

Kragen Sitaker kragen@pobox.com
Thu, 22 Jun 2000 03:02:40 -0400 (EDT)

Joshua Burton wrote, rationally:
> David Chase wrote:
> > >The unglamorous way of saying this is: "You have just re-invented the
> > >process."
> > 
> > Yes and no.  OS Interprocess communication is typically quite expensive.
> Depends on the OS, of course.  Threads are useful iff:
> (1) Coroutines are too small (you can't trust me to yield to you), BUT

Threads are useful for SMP scaling and for coping with system-call
interfaces that hang their callers for arbitrary amounts of time ---
two things coroutines can't do.  Processes can, of course.

Threads are also more flexible in when they can yield; you can be three
levels down a call chain and yield to another thread.  Doing this in
coroutines requires that you allocate a separate stack for each
coroutine, and poof, you've just written a userspace thread package.
See e.g. http://pobox.com/~kragen/minos, a tiny preemptive thread
package my twin cousin Ben implemented with SIGALRM, setjmp, and

The following is included so as not to distort the meaning of the post
to which I am replying:
> (2) Processes are too big (you trust me to dance all over your memory).

Oh, and if you have non-MMU methods of preventing this --- for example,
in Java, don't hand the bad guy a pointer, or in a pure functional or
logic language, trust the interpreter --- you don't need processes, at
all, ever, except to paper over broken system call interfaces (e.g. you
can only have N file descriptors open per process, or only run under
one or two or three UIDs per process, or only have one controlling tty
per process, etc.)

<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08.  Hurrah!
The power didn't go out on 2000-01-01 either.  :)