SPUG: Forked Children talking back to the parent?

Jeremy Devenport jeremy at weezel.com
Wed Jan 17 10:10:15 CST 2001


On a related note, does anybody know the current state of threads in perl? I
imagine they're probably still experimental but do they work enough to play
with? on windows? on *BSD?

# Jeremy Devenport
# ----------------
@? && print $?[4.8-($?/5)+($?++%5*5)] for @? = split
??, q?creAJklrnue  osrHPtt aeh ?, @? - $? && $? + @?;

-----Original Message-----
From: owner-spug-list at pm.org [mailto:owner-spug-list at pm.org]On Behalf Of
John Cokos
Sent: Wednesday, January 17, 2001 7:44 AM
To: spug-list at pm.org
Subject: SPUG: Forked Children talking back to the parent?


Working on a long running perl script, that I think would be better suited
to using fork() than running on it's own.

Basically, the pseudocode for it is something like this:



code:-----------------------------------------------------------------------
-------my @to_do_list

push @to_do_list, $something;

foreach my $item ( @to_do_list ) {

    .. do some work.
    if ( I find something else to do)  {
       push @to_do_list, $this_new_thing;
    }

}
----------------------------------------------------------------------------
--


So, you can see that it's an array that can be added to in mid-stream, and
continually grows. Depending on the amount of things
"found to do" in the inside loop, it can take hours and hours to run, as
that array grows larger.

What I'm wanting to do, is fork off 10 child processes, and have each of
them doing the same loop, each aware of the master array's
contents, and each able to push things onto it, so that the other children,
when they're in the loop see the new todo items...

Can the children intercommunicate?

If not, can they at least return a value back to the parent?
In this case, we could have it fork 10, give them a task, get back the new
todo items found, and die. Then, fork 10 new kids, etc
....

Thanks, John
========================================
  John Cokos, President / CEO: iWeb Inc.
  http://www.iwebsys.com
  jcokos at ccs.net
========================================



 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
  Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/




 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
  Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/





More information about the spug-list mailing list