Hi Norman --
Norman Ramsey wrote:
>
> I wonder if anybody on this list has come up with any good tricks
> for exploiting parallelism using ksh. Example: all the unit and system
> tests I run on the code my students submit for homework are written using
> ksh. Given that I have a four-processor machine, wouldn't it be
> nice to get through those tests four times faster? But I'm not sure
> I want to blithely launch as many processes as I have tests.
>
> Some form of work-crew parallelism would be ideal here.
> The shortest path I have thought of would be to have ksh generate a
> makefile that says what I want to have done, then use make to
> limit the amount of parallelism going on at once. (For example, I might
> want to tie up just 3 of my 4 cores running tests.)
>
> This procedure strikes me as a bit tedious. Does anybody have other
> ideas?
Just because the work is in ksh doesn't mean the execution wrapper
needs to be. There's a perl module called Parallel::Queue exactly for
this purpose, and the complete perl code to run your jobs in limited
parallel wouldn't be more than a few lines.
The algorithm itself is actually fairly simple, and if you really
wanted to, you could probably re-implement it in ksh. Programmatic job
control in ksh is tricky though, and in my experience, can be
unreliable. Here's a simple version that seems to work, albeit in an
ugly way.
#!/bin/ksh
while read task; do
$task &
while [[ `jobs | wc -l` -ge 3 ]]; do sleep 1; done
done
while [[ `jobs | wc -l` -gt 0 ]]; do sleep 1; done
--
Ron Isaacson
Morgan Stanley
[EMAIL PROTECTED] / (212) 276-1144
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users