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: Mike Frysinger
Subject: Re: Parallelism a la make -j <n> / GNU parallel
Date: Thu, 3 May 2012 18:01:04 -0400
User-agent: KMail/1.13.7 (Linux/3.3.4; KDE/4.6.5; x86_64; ; )

On Thursday 03 May 2012 16:12:17 John Kearney wrote:
> I tend to do something more like this
> 
>     function runJobParrell {
>         local mjobCnt=${1} && shift
>         jcnt=0
>         function WrapJob {
>             "${@}"
>             kill -s USR2 $$
>         }

neat trick.  all my parallel loops tend to have a fifo of depth N where i push 
on pids and when it gets full, wait for the first one.  it works moderately 
well, except for when a slow job in the pipe chokes and the parent doesn't 
push anymore in until that clears.

>         function JobFinised {
>             jcnt=$((${jcnt}-1))

: $(( --jcnt ))

or a portable version:

: $(( jcnt -= 1 ))

>         while [ $# -gt 0 ] ; do
>             while [ ${jcnt} -lt ${mjobCnt} ]; do
>                 jcnt=$((${jcnt}+1))

same math suggestion as above
-mike

Attachment: signature.asc
Description: This is a digitally signed message part.


reply via email to

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