Concurrent BASH: Utilize your Dual-Core or Quad-Core processors
Hence, I'm trying to design a system to overcome problems as mentioned. Your BASH program can do like the following:
prun.bash:Isnt that's cool? Multiple oggdec which decode ogg files will run in parallel on your dual-core or quad-core machine but with limited max number of threads at a time. The Dual-Core machine completes the decoding in merely 13.3s.
#!/bin/bash
cd /tmp/xman
date
for i in *.ogg ; dospawn oggdec *.oggdone
synchronize
echo "Done"
date
exit 0
xman@sai xman $ time ./prun.bash
Sun Aug 27 21:44:13 SGT 2006
Done
Sun Aug 27 21:44:26 SGT 2006
real 0m13.279s
user 0m0.020s
sys 0m0.072s
Now let me decode using serial script. The serial script:
xman@sai xman $ cat runSerial script is unable to utilize two cores simultenously. Hence, it's important to use concurrent facility in order to fully utilize the processors that you are using.
#!/bin/bash
date
for i in *.ogg ; do
oggdec "$i" &> /dev/nulldone
echo "Done"
date
exit 0
xman@sai xman $ time ./run
Sun Aug 27 21:38:26 SGT 2006
Done
Sun Aug 27 21:38:46 SGT 2006
real 0m20.625s
user 0m19.273s
sys 0m1.004s
Labels: BASH, Parallel computing