When there were fewer xlat headers, this didn't matter as much.
But now with >200, trying to run them all in parallel can easily
fork bomb smaller systems.

* xlat/gen.sh (main): Do not more jobs than # of cpus.
---
 xlat/gen.sh | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/xlat/gen.sh b/xlat/gen.sh
index 1484fb5..921f9fe 100755
--- a/xlat/gen.sh
+++ b/xlat/gen.sh
@@ -147,6 +147,8 @@ main()
        local input="$1"
        local output="$2"
        local name
+       local jobs=0
+       local ncpus=$(getconf _NPROCESSORS_ONLN)
 
        if [ -d "${input}" ]; then
                local f names=
@@ -156,6 +158,11 @@ main()
                        name=${name%.in}
                        gen_header "${f}" "${output}/${name}.h" "${name}" &
                        names="${names} ${name}"
+                       : $(( jobs += 1 ))
+                       if [ ${jobs} -ge ${ncpus} ]; then
+                               jobs=0
+                               wait
+                       fi
                done
                gen_git "${output}/.gitignore" ${names}
                gen_make "${output}/Makemodule.am" ${names}
-- 
2.3.0


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to