Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Multi-core loops
- X-seq: zsh-users 14212
- From: Wayne Davison <wayned@xxxxxxxxxxxxxxxxxxxxx>
- To: Nadav Har'El <nyh@xxxxxxxxxxxxxxxxxxx>
- Subject: Re: Multi-core loops
- Date: Wed, 1 Jul 2009 09:09:32 -0700
- Cc: zsh-users@xxxxxxxxxx
- In-reply-to: <20090628103129.GA15270@xxxxxxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20090628103129.GA15270@xxxxxxxxxxxxxxxxxxxxxxxxxx>
On Sun, Jun 28, 2009 at 01:31:29PM +0300, Nadav Har'El wrote:
> Instead, you'll want to keep all CPUs busy all the time, running M
> (=number of CPUs) processes at the same time.
Perl has a nice module for this. Perhaps we can steal ideas from this:
use Parallel::ForkManager;
my $pm = new Parallel::ForkManager(5); # limit to 5 parallel processes
foreach my $var (@array) {
# can do non-parallel-ized work here, as needed
...
$pm->start and next; # do the fork, parent skips to next loop
# use any perl commands you like here.
...
$pm->finish; # do the exit in the child process
}
pm->wait_all_children;
If we had something similar for zsh (perhaps using a loadable module),
it would make it easy to parallelize a sequence of shell commands
without having to use '&'.
..wayne..
Messages sorted by:
Reverse Date,
Date,
Thread,
Author