Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

threading perl

by tekniko (Deacon)
on Jun 15, 2001 at 21:34 UTC ( [id://88865]=perlquestion: print w/replies, xml ) Need Help??

tekniko has asked for the wisdom of the Perl Monks concerning the following question:

Enlighten me, please, as to why one would build a threading perl and what benefits one might derive thereafter.

Replies are listed 'Best First'.
Re (tilly) 1: threading perl
by tilly (Archbishop) on Jun 16, 2001 at 03:47 UTC
    Benefits. You get to play with experimental code and send back bug reports. If you are really ambitious you get to play your hand at hacking on the Perl core.

    Disadvantages. This stuff is experimental and most definitely not meant for production.

    For a longer, more detailed, explanation you can try Threads vs Forking (Java vs Perl).

Re: threading perl
by thraxil (Prior) on Jun 16, 2001 at 03:26 UTC

    take a good class on operating systems if you really want to understand all the details.

    in the meantime, here's my best shot at an explanation:

    threading allows for concurrency. concurrency means doing more than one thing at a time. the benefits of doing more than one thing at a time should be fairly obvious.

    of course, perl already has a form of concurrency with fork(), which spawns a new child process, so why would we care about threading? spawning processes is inefficient and cumbersome in many situations. spawning a process on most operating systems requires copying large chunks of memory and modifying process tables; this is slow. then, once the new processes are spawned, they're totally seperate; they can't share data very easily without the use of inter-process communications (IPC) which are tricky things to handle. making seperate processes work together on a single task gets mind-bogglingly difficult very quickly. (don't think i'm bashing fork() here; spawning new processes is a perfectly good way of accomplishing many tasks. i use fork() all the time.)

    so threading comes in for situations where you want to have lots of things going on at the same time, probably with a good deal of communication and cooperation between all of the seperate tasks (threads). it's probably simplest to think of threads as lightweight processes; the process of spawning a new thread is very similar to spawning a new process but involves far less copying and fewer calls to the operating system itself (which tend to have expensive context-switches). threads are also generally allowed to all access the same data (with some provisions for synchronization) which makes communication and cooperation significantly easier.

    if that's not terribly clean, let me know and i'll elaborate.

    anders pearson // digital samurai
    personal      // http://www.columbia.edu/~anders/
    weblog       // http://thraxil.dhs.org/
    
Re: threading perl
by malloc (Pilgrim) on Jun 15, 2001 at 22:38 UTC
    Sir, not sure about what exactly you are looking for, but oddly enough i found this article today on slashdot and found it fascinating, having an abundance of info on generic multithreading. Hope it is of some help, even though it is not perl specific.
    -malloc
      Ah...Now, this makes perfect sense. For some reason, I thought that Perl might be different. Do you know of any Perl-based projects dealing with distributed/parallel processing? Thanks!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://88865]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (7)
As of 2024-04-24 10:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found