in reply to Re: Is fork() my answer to using dual-cpu?
in thread Is fork() my answer to using dual-cpu?
This is exactly what I would suggest, with the added comment that I have used this approach with excellent results.
Your actual code may vary, depending on requirementsuse Parallel::ForkManager; $pm = Parallel::ForkManager->new(2); foreach my $input_file (@files) { my $pid = $pm->start and next; system("shell_script < $input_file"); $pm->finish; # Terminates the child process }
This works well on both Windows and UNIX, and as long as the OS manages the SMP tasks correctly, your threads will use both CPUs (one thread will only use one CPU, obviously) if needed.
Updates:
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Is fork() my answer to using dual-cpu?
by idsfa (Vicar) on Oct 25, 2005 at 19:47 UTC | |
by radiantmatrix (Parson) on Oct 26, 2005 at 18:58 UTC |