Commit f2947bdf authored by alex@thinkpad's avatar alex@thinkpad
Browse files

QEMU tests: updates for limiting CPU load

- counting active processes returns 1 when the system is idle (not 3)
- even if the system has only one CPU core, it needs to be able to start a new job
- poll the CPU load 10 times over a period of 0.5 seconds before making a decision

--HG--
branch : qemu
parent ba9dfe3c1245
......@@ -392,13 +392,20 @@ function job_limit_auto {
local max_number=$(((`nproc` + 1) * 2 / 3 ))
while true; do
# check how many processes are running on the system before deciding to start a new job
local procs_running=$(cat /proc/stat | grep procs_running | cut -d ' ' -f 2)
local procs_blocked=$(cat /proc/stat | grep procs_blocked | cut -d ' ' -f 2)
local current_number=$((procs_running + procs_blocked))
if [[ $current_number -lt $max_number ]]; then
local current_max=0
for i in 1 2 3 4 5 6 7 8 9 10; do
local proc_stat=$(cat /proc/stat)
local procs_running=$(echo "$proc_stat" | grep procs_running | cut -d ' ' -f 2)
local procs_blocked=$(echo "$proc_stat" | grep procs_blocked | cut -d ' ' -f 2)
local current_number=$((procs_running + procs_blocked)) # at least 1
if [[ $current_number -gt $current_max ]]; then
current_max=$current_number
fi
sleep 0.05
done
if [[ $current_max -le $max_number ]]; then
break
fi
sleep 0.5
done
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment