Tux

...making Linux just a little more fun!

perl: forking and children.... again

Ben Okopnik [ben at linuxgazette.net]


Wed, 4 Jul 2007 22:37:56 -0400

As sometimes happens, shortly - or not so shortly - after we finish a discussion in TAG, more info about the problem pops up out of nowhere, usually as a result of a completely unrelated Google search. I swear, if we were to have a discussion about Martian blood-drinking weasels, next week I'd run into a "The Vampire Mustelids of Ares: A Personal Interview" while searching for soap-scum removal info...

Anyway, Karl-Heinz: while I was fiddling about trying to come up with a "max-spread" sorting algorithm [1], I ran across a reference to Parallel::ForkManager on 'http://perlmonks.org'. Doing a quick lookup on CPAN came back with this (snipped from the documentation):

This module is intended for use in operations that can be done in
parallel where the number of processes to be forked off should be
limited.  Typical use is a downloader which will be retrieving
hundreds/thousands of files.
 
The code for a downloader would look something like this:
 
[...]
This sounds like exactly the kind of thing you were describing. It allows nicely fine-grained individual control of the child processes, etc. - take a look!

http://search.cpan.org/author/DLUX/Parallel-ForkManager-0.7.5/ForkManager.pm

There's also Parallel::ForkControl -

http://search.cpan.org/author/BLHOTSKY/Parallel-ForkControl-0.04/lib/Parallel/ForkControl.pm

[1] For the mathematicians among us, you might find this to be fun. See my next post.

-- 
* Ben Okopnik * Editor-in-Chief, Linux Gazette * http://LinuxGazette.NET *

Top    Back


Karl-Heinz Herrmann [kh1 at khherrmann.de]


Thu, 5 Jul 2007 09:01:54 +0200

Hi Ben,

On Wed, 4 Jul 2007 22:37:56 -0400 Ben Okopnik <[email protected]> wrote:

> Anyway, Karl-Heinz: while I was fiddling about trying to come up with a
> "max-spread" sorting algorithm [1], I ran across a reference to
> Parallel::ForkManager on 'http://perlmonks.org'. Doing a quick lookup on
> CPAN came back with this (snipped from the documentation):

Hmm...

> This module is intended for use in operations that can be done in
> parallel where the number of processes to be forked off should be
> limited.  Typical use is a downloader which will be retrieving
> hundreds/thousands of files.

yes -- doesn't hit my problem directly (one thread which is not breaking down would be good enough) but sounds very interesting for other applications.

> http://search.cpan.org/author/DLUX/Parallel-ForkManager-0.7.5/ForkManager.pm
> 
> There's also Parallel::ForkControl -
> 
> http://search.cpan.org/author/BLHOTSKY/Parallel-ForkControl-0.04/lib/Parallel/ForkControl.pm

Thanks for the links...

K.-H.


Top    Back