[ltp] this script controles on my t60 the cpufunctions i use

Alfredo Matos linux-thinkpad@linux-thinkpad.org
Wed, 16 Aug 2006 11:29:15 +0100


Hi,

So this enables and disables the second core.
You do this for powersave reasons i presume. Do you have a notion of the
battery gain, i mean, how much more (in minutes) are you able to squeeze
out of the battery ?

Best regards, and nice work.

Alfredo Matos

Florian Manschwetus wrote:
> ok it is a little bit bash.
> use it or read it for informations how it work
> or just skip it ;)
> florian
>
> #!/bin/bash
>
> CPU1_STATE=$(cat /sys/devices/system/cpu/cpu1/online)
> echo state read from cpu
>
> if [[ ${1} == 0 && ${CPU1_STATE} == 1 ]]; then
>         echo disabling
>         CPU1_GOVERNOR=$(cat
> /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor)
>         echo governor readed
>         echo -e "CPU1_GOVERNOR=${CPU1_GOVERNOR}\n" > /tmp/core1_state
>         echo state saved
>         echo userspace >
> /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor
>         echo 0 > /sys/devices/system/cpu/cpu1/online
>         echo cpu now offline
> fi
>
> if [[ ${1} == 1 && ${CPU1_STATE} == 0 ]]; then
>         echo enabling
>         source /tmp/core1_state
>         echo state read
>         rm /tmp/core1_state
>         echo file deleted
>         echo 1 > /sys/devices/system/cpu/cpu1/online
>         echo cpu now online
>         echo ${CPU1_GOVERNOR} >
> /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor
>         echo governor restored
> fi
>
> if [ ${1} == "reset" ]; then
>         echo reset
>         if [ ${2} == "all" ]; then
>                 echo ondemand >
> /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
>         fi
>         if [ ${CPU1_STATE} == 0 ]; then
>                 echo cpu is down
>                 echo 1 > /sys/devices/system/cpu/cpu1/online
>                 echo cpu now online
>         fi
>         echo setting governor
>         echo ondemand >
> /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor
>         echo governor set to ondemand
> fi