configure: Prevent spawning more subprocesses than CPUs available.
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
This commit is contained in:
parent
cf7a9b69b2
commit
827c4d1466
10
configure
vendored
10
configure
vendored
@ -24,19 +24,21 @@ CONFIG_FILE=$SCRIPTPATH/"config.out"
|
|||||||
generate_config() {
|
generate_config() {
|
||||||
rm -f ${CONFIG_FILE}
|
rm -f ${CONFIG_FILE}
|
||||||
touch ${CONFIG_FILE}
|
touch ${CONFIG_FILE}
|
||||||
declare -a pid_list
|
n_cores=$(nproc)
|
||||||
progress=0
|
|
||||||
|
|
||||||
# Compile each test module in background
|
# Compile each test module in background
|
||||||
echo "Preparing configuration"
|
echo "Preparing configuration"
|
||||||
for file in $CONFIG_FILES; do
|
for file in $CONFIG_FILES; do
|
||||||
progress=$((progress+1))
|
|
||||||
# $1 - Action to be performed
|
# $1 - Action to be performed
|
||||||
# $2 - File with stored configuration
|
# $2 - File with stored configuration
|
||||||
# $3 - Name of called script (since script is running as subprocess
|
# $3 - Name of called script (since script is running as subprocess
|
||||||
# it has to be passed explicitly)
|
# it has to be passed explicitly)
|
||||||
source $file "check" "$CONFIG_FILE" "$file" &
|
source $file "check" "$CONFIG_FILE" "$file" &
|
||||||
pid_list+=($!)
|
|
||||||
|
# Prevent spawning more subprocesses than CPU available
|
||||||
|
while [ $(ps --no-headers -o pid --ppid=$$ | wc -w) -ge $n_cores ] ; do
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
# Wait for all compilation processes to finish
|
# Wait for all compilation processes to finish
|
||||||
|
Loading…
Reference in New Issue
Block a user