Optimize cpuspeed / Ajustement cpuspeed

Moderators: digital, horus

Optimize cpuspeed / Ajustement cpuspeed

Postby analyzer on 16 Mar 2008, 01:47

CPUSPEED always set the cpu frequency on demand ...

This is quite good, but I want that if the AC Adapter is connected, then we go in "performance" mode, else back to "ondemand" !

While ACPID uses events, we can easily use them to manage cpuspeed to increase or decrease the frequency of processor(s).

1) Create a file named "ac_adapter.conf" in "/etc/acpi/events", and will contain:
Code: Select all
event=ac_adapter
action=/etc/acpi/actions/ac_cpu.sh


This will trigger the event when AC Adapter is plugged in or off.

2) Create a file named "ac_cpu.sh" in "/etc/acpi/actions", and write:
Code: Select all
#!/bin/bash
ac_state=`cat /proc/acpi/ac_adapter/ADP1/state`
if [[ "$ac_state" =~ "on-line" ]] ; then
        echo "performance" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
        echo "AC Power Connected - Sent SIGUSR1 signal to cpuspeed for getting a fast static CPU"
else
        echo "ondemand" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
        echo "No AC Power Connected - Sent SIGHUP signal for going back to dynamic CPU speed"
fi


"/proc/acpi/ac_adapter/ADP1/state" may vary for you (eg. "/proc/acpi/ac_adapter/AC/state")

This script will be called whenever an action is made to AC Adapter !

3) "/etc/init.d/acpid restart" to make changes effective
analyzer
Administrateur
Administrateur
 
Posts: 27
Joined: 22 Mar 2005, 19:37

Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron