Subject: Re: libpthread
To: Greywolf <greywolf@starwolf.com>
From: Greg A. Woods <woods@weird.com>
List: current-users
Date: 06/20/2003 22:49:46
[ On Friday, June 20, 2003 at 17:19:44 (-0700), Greywolf wrote: ]
> Subject: Re: libpthread
>
> I'll also be honest in stating that programming for/with threads is
> completely mystifying to me; it seems to me an exercise in implementing
> kernel-level complexity into userland programming, but that's probably
> my ignorance showing.

No, I think you nailed that issue square on the head.

The only thing more complex and difficult than programming and debugging
threaded applications in userland is writing and debugging a portable
SMP kernel, and probably the only thing more complicated than doing that
is writing kernel level code to support threaded applications with
kernel threads, especially in an SMP kernel.

At least I think that's true if you're just writing your code in
Standard C.

There are some key advantages though to multi-threading with the support
of kernel-level threads on SMP architecture which specific types of
applications really can take direct advantage of having multiple
simultaneous threads of execution while using a monolithic address space
for efficiency's sake.  Examples are things like user-interfaces (GUI
servers such as Xserver, but probably not your window manager),
interpreters for languages that have more natural ways of expressing
concurrent execution (e.g. smalltalk), virtual machine emulators, and
maybe some types of server applications which must multiplex with
clients while doing lots of back-end I/O (e.g. a database server).
Obviously you really don't need or want any of those kinds of
applications pushed down into kernel land just so they can take
advantage of multiple CPUs, and designing them to use multiple processes
instead may also be rather difficult, even with shared memory and other
efficient and powerful IPC mechanisms (though of course these
difficulties shouldn't stop anyone from trying such designs! ;-)

The problem is there are just too many macho programmers who think they
can tackle at least the use of application-level threads using only
plain old C and now too many people are getting the impression that an
operating system isn't useful or modern unless it has kernel level
thread support for all the many dozens of unnecessarily threaded
applications.

-- 
								Greg A. Woods

+1 416 218-0098;            <g.a.woods@ieee.org>;           <woods@robohack.ca>
Planix, Inc. <woods@planix.com>; VE3TCP; Secrets of the Weird <woods@weird.com>