parallel
[Top][All Lists]
Advanced

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

I don't understand this behaviour


From: D. R. Evans
Subject: I don't understand this behaviour
Date: Sun, 22 Jan 2017 19:22:03 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.6.0

Could someone please explain the following to me? I expect that I'm missing
something simple, but I don't understand what I am seeing.

I have a bash script, the relevant part of which looks like this:

----

for (( yr=$MIN_YEAR; yr <= $MAX_YEAR; yr++))
do

  echo "creating maps for $yr"

  sem -j-1 rbn-posters-map.py [parameters to python script]
  sem -j-1 rbn-posters-map.py [parameters to python script]
  sem -j-1 rbn-posters-map.py [parameters to python script]
  sem -j-1 rbn-posters-map.py [parameters to python script]
  sem -j-1 rbn-posters-map.py [parameters to python script]
  sem -j-1 rbn-posters-map.py [parameters to python script]
  sem -j-1 rbn-posters-map.py [parameters to python script]
  sem -j-1 rbn-posters-map.py [parameters to python script]
  sem -j-1 rbn-posters-map.py [parameters to python script]

done

sem --wait

echo "After wait"
ps auxw | grep rbn

----

My understanding, which is obviously incomplete, was that the "sem --wait"
command would cause the script to block until all the various "rbn-posters.py"
jobs that had been started with sem had completed. Therefore, I expected that
the "ps" command would find none of those jobs still to be running.

However, what actually happens, consistently, is that 3 such jobs are running
when the "ps" command is executed (on this machine there are four cores).

I need to have all the jobs completed at the point where the "ps" is currently
placed, so that the next part of the script will run correctly. But at the
moment, because not all the "rbn-posters.py" jobs have completed, the next
part fails.

I welcome enlightenment as to why the "sem --wait" isn't doing what I
expected. (And bonus points if someone can explain how to modify the sem
commands in the script so as to be sure that they have all completed at the
point where the "ps" is currently located, preferably while still allowing
parallel execution of the "rbn-posters.py" jobs.)

I thank you very much.

  Doc Evans

-- 
Web:  http://www.sff.net/people/N7DR

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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