Setting the online status of the CPU core just tells the process scheduler to not use that core for any processes. On a hardware level, the core is simply sitting idle (doing NOPs), but still powered. While this will save power, it won't save nearly as much power as putting the computer to sleep. Why?
Well, your motherboard, CPU, and GPU are all still running!
When you put the computer to sleep, all of these components are
literally unpowered, and just enough power to keep your RAM alive is
used (on the order of a couple watts).
Again, while I agree it will save power, even shutting off half of
your CPU cores may halve the power consumption of the processor
(although in reality, you may only save 30-40% since those cores still
need to sit idle), but this is far from the only component in the system
using power. Even if you save 50W by doing this, you're entire
computer is still drawing far more power than mere watts in sleep mode.
Final thoughts: While I agree this is a great idea in practice, this
is also why many CPU manufacturers include dynamic frequency scaling
(Intel's "Speed Step"), with support for Linux. You may yield better
overall performance, as well as power efficiency, by setting these
frequencies more appropriately for your needs. This can be done in both
hardware (BIOS settings), as well as software (the Linux kernel allows
you to modify some CPU parameters, see the link I posted above or for details).
This works, because the following is the generic equation for power consumption of a CMOS circuit:
P = CV2f, where C = capacitance (assume fixed), V = voltage, and f = frequency.
Thus, dividing the frequency by 2 will half the original power
consumption. Dividing the voltage by 2 will reduce power consumption to
1/4 the original.
http://blog.sina.com.cn/s/blog_858820890101cplt.html
转自:
http://sunj.iteye.com/blog/1940948
Linux双核cpu转为单核运行 echo 0 >
/sys/devices/system/cpu/cpu1/online
若你机器是双核的cpu,上面命令使你的第二个内核停止运行。
这样/sys/devices/system/cpu/cpu1/下的所有关于第二个内核的文件消失。
单核运行,cpu很容易就飙到100的,只需移动一下窗口。不知道省电否。
echo 1 >
/sys/devices/system/cpu/cpu1/online
恢复双核运行
cat /sys/devices/system/cpu/online
可以显示你的当前工作的cpu数。
echo powersave >
/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
可以设置你的cpu为省电模式
cat
/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
可用的模式
[root@shine cpufreq]# ls
affected_cpus
related_cpus
scaling_governor
cpuinfo_cur_freq
scaling_available_frequencies
scaling_max_freq
cpuinfo_max_freq
scaling_available_governors
scaling_min_freq
cpuinfo_min_freq
scaling_cur_freq
scaling_setspeed
cpuinfo_transition_latency
scaling_driver
stats
网上看到的脚本不知道是否管用
#!/bin/bash
# author: fcicq
# requirement:
# acpi,cpufreq
# a Dual Core CPU (like Intel core
2)
chkavg() {
thisloadavg=`cat /proc/loadavg | awk -F . '{print
$1}'`
if [ $thisloadavg -ge 2 ]; then
# >2
if [ `cat /sys/devices/system/cpu/cpu1/online` -eq 0 ];
then
echo 1 >
/sys/devices/system/cpu/cpu1/online
fi
cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq >
/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
cat /sys/devices/system/cpu/cpu1/cpufreq/cpuinfo_max_freq >
/sys/devices/system/cpu/cpu1/cpufreq/scaling_setspeed
elif [ $thisloadavg -ge 1 ];
then
# 1-2
if [ `cat /sys/devices/system/cpu/cpu1/online` -eq 1 ];
then
echo 0 >
/sys/devices/system/cpu/cpu1/online
fi
cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq >
/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
else
# 0-1
if [ `cat /sys/devices/system/cpu/cpu1/online` -eq 1 ];
then
echo 0 >
/sys/devices/system/cpu/cpu1/online
fi
cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq >
/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
fi
}
while true; do
chkavg
sleep 60
done