Reputation: 431
The target is the following: I have 40 FPGAs in total. 10 FPGAs are connected to a single programmer, i.e., I have 4 programmers to flash all 40 FPGAs. The FPGAs can only be programmed consecutively at each programmer.
Now I need a loop which programs all 40 FPGAs. In order to speed up / accelerate the process I would like to program the FPGAs of 4 programmers in parallel, i.e., 4 flash scripts in parallel. The flashing process must be finished before executing the next flashing process of each programmer. For simplicity let's assume the FPGAs are numbered from 01 to 40.
This means that FPGA02 can be only flashed when FPGA01 finished. But FPGA01, FPGA11, FPGA21 and FPGA31 should be flashed in parallel.
The problem for the code below is that the process does not wait until the flashing is finished.
for i in `seq 1 10`
do
my_flash_script.py --FPGA 0$i &
done
Upvotes: 1
Views: 48
Reputation: 212198
Seems like you are backgrounding the wrong thing. Try:
for i in $(seq -w 1 10); do my_flash_script.py --FPGA $i; done &
for i in $(seq -w 11 20); do my_flash_script.py --FPGA $i; done &
for i in $(seq -w 21 30); do my_flash_script.py --FPGA $i; done &
for i in $(seq -w 31 40); do my_flash_script.py --FPGA $i; done &
wait
(And notice that this becomes much more natural if you number your devices 0 to 39, but that's a different issue entirely.)
Upvotes: 2