Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Thread vs. Fork

by rpc (Monk)
on Feb 16, 2001 at 22:58 UTC ( [id://58934]=note: print w/replies, xml ) Need Help??


in reply to Thread vs. Fork

Threads aren't necessarily being phased out, and certainly aren't being scoffed at. They will be an integral part of Perl6. Threads and fork() are significantly different technologies. perl5 didn't begin as a multithreaded interpreter, and I think the fact it supports threading at all is amazing.

--rpc

Replies are listed 'Best First'.
Re: Re: Thread vs. Fork
by deadkarma (Monk) on Feb 17, 2001 at 00:51 UTC
    If perl6 has multi-threads as standard, that would be so great. I'm really amazed at how far the language has come.
    I've never used fork(), and even after reading documentation, I don't really understand how it works and how it's different that using system() or backticks.
      Here are some quick answers for you. For more indepth info just do a search of this site:
      • system, stripped down of security features, is simply a fork() and exec(). fork() creates a new process space which exec() populates with whatever process you specified in the shell call.
      • Backticks fire off the shell call in a separate process, then captures STDOUT from it.
      • Threads have far less overhead than a process and are contained within the process which allows concurrent handling of instructions.
      • You may fork() and specify further perl code instead of an exec so that you end up with multiple perl interpreters running in separate process spaces.
      • At any time, you can call exec() which then "overwrites" the process space with a new binary with some exceptions like file descriptors. This is useful to redirect streams before handing over the streams to some process.

      AgentM Systems nor Nasca Enterprises nor Bone::Easy nor Macperl is responsible for the comments made by AgentM. Remember, you can build any logical system with NOR.
      There is a reasonable discussion of how threading and fork differ technically and philosophically at Threads vs Forking (Java vs Perl). In that discussion KM came out with Mr. Peabody Explains fork() which is a very good starting place if you just want to understand what fork is and why it was invented. (In fact I recommend reading it before my link.)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (8)
As of 2024-04-23 08:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found