Microcebus has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks,
I have a perlscript called swap.pl an want to start it several times with another perl script to use my 4 CPU cores. Each time, the swap.pl script processes a different part of a given dataset. My code looks like:
foreach(1..$number_of_cpus) { open(TEMP_CTRL,">temp_ctrl"); print TEMP_CTRL "$_"; # contains information for swap.pl close TEMP_CTRL; system("swap.pl"); # swap.pl reads temp_ctrl to know which part of + the dataset to process sleep(1); }
The problem is, that the system command waits until the process is finished, which means there is no parallelization at all. And the problem with exec command is that it does not return.
Can anyone help?UPDATE: Thanks for the suggestions. I found
to work well.system(1,"swap.pl")
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: exec vs. system
by derby (Abbot) on Jul 07, 2011 at 12:32 UTC | |
|
Re: exec vs. system
by jethro (Monsignor) on Jul 07, 2011 at 12:29 UTC | |
by jpl (Monk) on Jul 07, 2011 at 17:39 UTC | |
by Microcebus (Beadle) on Jul 07, 2011 at 13:08 UTC | |
by jethro (Monsignor) on Jul 07, 2011 at 14:30 UTC | |
by jpl (Monk) on Jul 07, 2011 at 18:00 UTC | |
|
Re: exec vs. system
by tokpela (Chaplain) on Jul 07, 2011 at 19:34 UTC | |
|
Re: exec vs. system
by locked_user sundialsvc4 (Abbot) on Jul 07, 2011 at 12:34 UTC | |
by Anonymous Monk on Jul 07, 2011 at 12:51 UTC |