Currently I'm stuck at running time consuming simulations efficiently. The intention is to run 4 simulations in parallel, because it's a single thread application and a quad core system. I have to variations of shell script:
./sim -r 1 &
./sim -r 2 &
./sim -r 3 &
./sim -r 4 &
wait
./sim -r 5 &
./sim -r 6 &
./sim -r 7 &
./sim -r 8 &
wait
... (another 112 jobs)
with this code there is a wait again and again. I also tried to split the tasks into four scripts and run each, result is that one script is finished while the other has about 30% of remaining jobs. I can't predict how long a simulation will take.
Any suggestion to have 4 simulations running at any time?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…