I spent some time thinking about Dr. Ruud's reply over the past several
days.  Although I mostly share his views, I think that he has done a
disservice to the discussion of the relative merits of threading and forking
.  Like most things in technology different approaches exploits different
trade-offs.  Usually not one approach is superior to all others in all
situations.  (cf. Python vs Perl vs Ruby, eg. )

Here is my opinion on the matter.

Forking is a simpler and cleaner approach.   By design the programmer does
not have to worry about sharing of data and race conditions.  When you
algorithm is limited in memory requirements and completely
compartamentalized, this is a good choice.
And this is very often the case.

Threading is not without its place, however.  Notwithstanding, Dr. Ruud's
argument:

Most wishes for "readily-shared memory" result from (and to) bad design.

This argument, stated without proof, makes a grand generalization.  There
are quite a few algorithms: sort, search, merge that greatily benefit from
shared (or increased) memory.  The simplest is using a very large shared
hash to map values from a very, very large data stream.  The ability of the
shared memory will allow for more cooperative threads than forks where
memory cannot be shared.

It is possible to marshall, serialize, or use other IPC between forks, but
then the balance of simpler, cleaner probably tilts toward a threading
solution.

I hope this provides some clarity for the original poster.

Best,

Chris




On Sun, Nov 2, 2008 at 8:03 AM, Dr.Ruud
<[EMAIL PROTECTED]<[EMAIL PROTECTED]>
> wrote:

> "Dana Hudes" schreef:
> > Dr.Ruud:
> >> Gabor Szabo:
>
> >>> I guess we can implement everything with fork but I think -
> >>> maybe because of my lack of experience in threads - that it will
> >>> be better to use them than to fork.
> >>
> >> I think it was Randal Schwartz who said something like: If the answer
> >> involves threads, then the question was wrong.
> >
> > Then Randall is wrong
>
> No, he wasn't. And isn't either. You are, and not only because you
> misspelt his name.
>
>
> > The Perl threading model is perhaps imperfect but the principle of
> > threads is a part of many modern applications not to mention every
> > modern OS including Solaris and MS windows xp
>
> And they are happily moving away from it, see for example the new IE
> design. With current hardware, forking nog longer has the issues that
> many people just can't appear to forget about.
>
>
> > Many client/server apps benefit from threading. Parallel processing
> > hugely benefits from threading b/c you have readily-shared memory
>
> Most wishes for "readily-shared memory" result from (and to) bad design.
>
> --
> Affijn, Ruud
>
> "Gewoon is een tijger."
>
>

Reply via email to