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

Forks and Spoons

by Mr.T (Sexton)
on Aug 09, 2001 at 23:33 UTC ( #103587=perlquestion: print w/replies, xml ) Need Help??
Mr.T has asked for the wisdom of the Perl Monks concerning the following question:

Hello Fellow Monks:

Once again, I have found out about a new term I don't know about, which is a 'fork' or 'forking' in Perl. I have seen it used frequently, but I have no clue as to:
  1. What does it do?
  2. When is it best to use?
  3. Is it anything like multithreading is in Java?
Any help on this topic would be gratefully appreciated!

qw/"I pity da foo' who don't use Perl!"/;

Replies are listed 'Best First'.
Re: Forks and Spoons
by dragonchild (Archbishop) on Aug 09, 2001 at 23:40 UTC
    Forking is, at its heart, a Unix term. It has to do with multi-processing, not multi-threading.

    A quick primer. Processes are how the OS (be it Unix, Win32, or whatever) keeps track of the things that are using its CPU, RAM, etc. It is the way that a single-CPU machine can have multiple things happen on it at once, through the miracle of timeslicing. (If you want to read more, search for timeslicing on your favorite search engine.)

    Threads are "processes within processes". According to the CPU, there's only one thing executing. According to the code, there's multiple things.

    The reasons you want to fork are numerous. It could be anything from wanting to do data-munging in parallel to a web server handling multiple requests of a CGI script to the gods know what. What I've discovered is that, in over 8 years of programming, I've never wanted to fork ... not even once. Others work with forking on a daily basis.

    There are a number of headaches dealing with forking, such as parent-child relationships, race conditions, data-sharing, signalling/communication, and overflowing the OS's process table ... just to name a few of the more common ones. If you do want to fork, read up on it. A lot. Then, read some other people's code. Try it out. Expect to have a number of issues and questions pop up.

    Good luck. *winces*

    /me wants to be the brightest bulb in the chandelier!

    Vote paco for President!

Re (tilly) 1: Forks and Spoons
by tilly (Archbishop) on Aug 09, 2001 at 23:46 UTC
Re: Forks and Spoons
by thatguy (Parson) on Aug 09, 2001 at 23:42 UTC
      i belive the quote is "If you can't find it with super search, it aint a substring of a text field in your database"

      (found that here)


      Oh cool! There is a super search? I'll have to try that out. Does it find more specific searches or something, and thus is superior to basic searching?

      qw/"I pity da foo' who don't use Perl!"/;
Re: Forks and Spoons
by RayRay459 (Pilgrim) on Aug 10, 2001 at 00:55 UTC
    You really have to read the Learning Perl and Programming Perl. I had so many of the same questions as you when i started and these, i hear, are the best out there. I have finished reading Learning Perl cover to cover. I am working on Programming Perl, and i learn something new all the time. just thought i'd put my 2 cents in. :) Ray

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://103587]
Approved by root
and the leaves swirl about...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2018-01-21 05:47 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (227 votes). Check out past polls.