首页 > 代码库 > disable cpu

disable cpu

根据我现在的判断,disable cpu 有两种方式。

第一种,在root的时候,进行 disable

Choose e and you get to a command line where you can add options.

You can also create permanent boot option in grub by making a copy of your current boot option and add maxcpus=1 to the boot parameters. You can name this Ubuntu, kernel 2.5.12-9-386 (1 cpu) and have it amongst the other boot options like the picture shows.

You can verify running on 1 cpu by issuing:

cat /proc/cpuinfo   | grep processor this should show something like this:

第二种,进行 Hotplug

You can dynamically disable CPUs via /sys/devices/system/cpu/cpuN/online, for example to disable CPU 1, use:

echo 0 | sudo tee /sys/devices/system/cpu/cpu1/online

cat /sys/devices/system/cpu/online (to check online cpu)
cat /sys/devices/system/cpu/offline (to check offline cpu)
re
-enable, use: echo 1 | sudo tee /sys/devices/system/cpu/cpu1/online

 

见网页:http://askubuntu.com/questions/46011/is-it-possible-to-disable-a-cpu-not-a-core  

    https://www.cyberciti.biz/faq/debian-rhel-centos-redhat-suse-hotplug-cpu/

 

tee 是需要有sudo 权限才能运行的。

disable cpu