bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Parallelism a la make -j <n> / GNU parallel


From: Greg Wooledge
Subject: Re: Parallelism a la make -j <n> / GNU parallel
Date: Fri, 4 May 2012 15:11:41 -0400
User-agent: Mutt/1.4.2.3i

On Fri, May 04, 2012 at 09:02:27PM +0200, John Kearney wrote:
> set -m
> cnt=0
> trap ': $(( --cnt ))' SIGCHLD
> set -- {0..20}
> while [ $# -gt 0 ]; do
>       if [[ ${cnt} -lt 10 ]] ; then
> 
>               (
>                       d=$(( RANDOM % 10 ))
>                       echo $n sleeping $d
>                       sleep $d
>               ) &
>               : $(( ++cnt ))
>               shift
>       fi
>       echo going to wait
>       sleep 1
> done

You're busy-looping with a 1-second sleep instead of using wait and the
signal handler, which was the whole purpose of the previous example (and
of the set -m that you kept in yours).  And $n should probably be $1 there.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]