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!


In reply to Re: Forks and Spoons by dragonchild
in thread Forks and Spoons by Mr.T

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.