Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^2: threads: spawn early to avoid the crush.

by BrowserUk (Patriarch)
on Mar 02, 2006 at 14:08 UTC ( [id://533885]=note: print w/replies, xml ) Need Help??


in reply to Re: threads: spawn early to avoid the crush.
in thread threads: spawn early to avoid the crush.

If the main program needed another process it would ask the original parent to do it for it.

Could you explain that in a bit more detail for me? I've never done much with fork, especially in Perl.

  • How does the main code inform it's parent when it is time to create another process?
  • If there can be multiple other processes that might need to be run, how does the main code tell teh parent which one to create?
  • How does the new process get it's parameters?
  • How does the main code retrieve the results from the new process?

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
  • Comment on Re^2: threads: spawn early to avoid the crush.

Replies are listed 'Best First'.
Re^3: threads: spawn early to avoid the crush.
by Anonymous Monk on Mar 02, 2006 at 16:46 UTC
    Here's a simple answer to interprocess communication: use pipes.
    #!/usr/bin/perl -w #use forking open to start 3 more processes unless (open X, "-|") { print 1+5; exit }; # X=1+5 unless (open Y, "-|") { print 2*3; exit }; # Y=2*3 unless (open Z, "-|") { print <X>+<Y>; exit }; # Z=X+Y print "Z = "; print <Z>."\n";

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2024-04-19 14:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found