[Chicago-talk] Speaking of threading
gdf at speakeasy.net
Tue Dec 9 10:38:49 CST 2003
On Mon, 08 Dec 2003 08:35:24 -0600, Steven Lembark <lembark at wrkhors.com> wrote:
> Noone ships with much of anything threaded by default, aside
> from perhaps POSIX & linux threads in libc.
You mean no one ships with threaded Perls by default?
> Threads are pretty
> much a non-issue for anyone that doesn't really knead them.
> Part of that is due to the fairly painful nature of threads
> in most situations: all you really get from a thread is your
> own instruction counter and exit status buffer. Perl's model
> (at least as of 5.8) is quite a bit more managable and may
> help change people's minds.
Frankly, having worked lot with standard Unix fork()-based
multiprocessing and with more "modern" threaded environments (Java,
Python, Ruby, etc), the advantages of threading over fork() are pretty
Once you have threading available, you have a whole bag of tricks
available to you that people go to fantastic lengths to avoid (eg, see
POE's choice of cooperative multitasking... my first reaction was,
"what is this, Windows 3.1?"). Even having to think about deadlock
is easier than worrying about fork-bombing, end-status notification,
child collection, IPC, et al. And, being able to (safely, easily,
portably) do more than one thing at once is pretty powerful, and
As an example example, one of the common patterns in Java programs is
the thread/task pool, which is pretty trivial to implement in an
environment with lightweight threads. Doing it with fork() is pretty
painful (one of the reasons the Subversion folks chose to use Apache
as their engine, rather than trying to write their own pre-forking
server scratch... a C example, but the techniques and issues for
forking with Perl are basically the same).
So I've always been a little confused that ithreads haven't been
pushed more than they have.
> Installing a threaded perl is mostly a matter of running
> 'perl -V' to see the original config arg's, then running
> Configure with '-de', a new preifx and threading argument.
Easy for you, easy for me, not so easy for Grandma.
 POE is pretty cool, though.
 By "portably", I mean "given two ports of language X, the same
code will run under both". fork() is not "portable" (though it's
*mostly* portable, these days).
More information about the Chicago-talk