NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Script to adjust cpu frequency according to cpu temprature




Hi,

I have searched through Google and maling lists, and couldn't find a good script that adjusts cpu frequency with respect to cpu temperature (there are different approaches as far as i see).

This is very important for notebooks, and generally cooling problem arises once a script (especially compiling process) uses cpus for along time. In other words, this small script helps your notebook to live longer (hopefully).


How to use:

1- According to number of cpus, add/remove temp{0} lines. Below one is for core duo cpu and it checks temperature of both core. I would first test value of 'envstat | grep cpu0 | cut -d \ -f 9 | cut -b 1,2' command to make sure it gives the temperature of the core 0.

2- Check your supported frequncies by 'sysctl -a | grep machdep.est.frequency.available' command...

3- Add/remove and adjust elif/then sections according to your cpu frequncies supported and desired temperature levels. Below one ie; reduces frequency to 1400 MHz once temperature is higher than 60 C degree and below 65 C degree.

4- Create a crontab and run the script every ie; 5 mins.


#######################################
#!/bin/sh

temp0=`envstat | grep cpu0 | cut -d \  -f 9 | cut -b 1,2`
temp1=`envstat | grep cpu1 | cut -d \  -f 9 | cut -b 1,2`

 if [ ${temp0} -gt 65 ] || [ ${temp1} -gt 65 ];
then sysctl -w machdep.est.frequency.target=1200

elif [ ${temp0} -gt 60 ] || [ ${temp1} -gt 60 ];
then sysctl -w machdep.est.frequency.target=1400

elif [ ${temp0} -gt 55 ] || [ ${temp1} -gt 55 ];
then sysctl -w machdep.est.frequency.target=1600

elif [ ${temp0} -gt 50 ] || [ ${temp1} -gt 50 ];
then sysctl -w machdep.est.frequency.target=1800

elif [ ${temp0} -gt 45 ] || [ ${temp1} -gt 45 ];
then sysctl -w machdep.est.frequency.target=2000

elif [ ${temp0} -gt 40 ] || [ ${temp1} -gt 40 ];
then sysctl -w machdep.est.frequency.target=2200

else
fi
#######################################


Use at your own risk of course.


Best regards,
Cem










Home | Main Index | Thread Index | Old Index