I have an Ubuntu server, which has 16 CPUs. (nproc --all
show me 16
)
I wrote a bash script named test.sh
as below:
#!/bin/bash
while :
do
echo xxx
done
I executed it: ./test.sh >/dev/null &
.
Then I used the command top
to monitor the cpu usages and I found that one cpu had been used almost 100% because of the process test.sh
:
6411 me 20 0 11240 3052 2852 R 93.8 0.0 0:11.71 test.sh
%Cpu5 : 96.7 us, 3.3 sy, 0.0 ni, 0.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
As we can see, the process test.sh
has been assigned on the 5th CPU, which has been used almost 100%.
Is it possible to assign a heavy process on more than one CPU so that we could make more use of CPUs? Why didn't the OS assign the process test.sh
on more than one CPU? Is it because that the process test.sh
is not heavy enough or should we do some configuration for the OS to do so?