CPUFreq_Interface Class Reference

#include <cpufreq_interface.h>

Inheritance diagram for CPUFreq_Interface:

CPU CPUFreq_Kernel CPUFreq_Userspace List of all members.

Public Member Functions

 CPUFreq_Interface (std::list< int > cpu_list)
 constructor
virtual ~CPUFreq_Interface ()
 destructor
virtual bool init ()=0
 checks if current cpu_id has a cpufreq directory and that it is no symlink
virtual int adjustSpeed ()=0
 adjusts speeds
virtual void reinitSpeed ()=0
 reinits speeds
virtual void setConfig ()=0
 set configuration in initialize values
void setConfigs (int high_cpu, int max_limit, int hysters, int consider_nice)
 Update configs and apply them.
int setGovernor (const std::string &new_governor)
 set a ne cpufreq governor
int setMode (CPUFREQ_MODE mode)
 set the current cpufreq policy
virtual bool readFrequencies ()=0
 reads out frequencies
CPUFREQ_MODE getMode ()
 get current cpufreq policy

Static Public Member Functions

static bool read_line (const char *filename, char *line, unsigned len)
 read a line from a file
static bool write_line (const char *filename, const char *fmt,...)
 write a line to a file

Static Protected Member Functions

static unsigned read_value (const char *filename)
 read an integer value from a file

Protected Attributes

string GOVERNOR_FILE
 file where active governor is in
string MIN_SPEED_FILE
 file containing the minimum freq
string MAX_SPEED_FILE
 file containing the maximum freq
string AVAILABLE_FREQS_FILE
 file containing available frequencies
int _cpu_max
 value specifying when to switch up
int _cpu_hysteresis
 value avoiding constant up/down switching
int _high_cpu_limit
 if the load difference is higher than this go directly for full speed
int _consider_nice
 if niced processes should also count
CPUFREQ_MODE _mode
 stores the current cpufreq policy
std::list< int > _cpu_cores
 list holding all cores which are affected by this interface

Constructor & Destructor Documentation

CPUFreq_Interface::CPUFreq_Interface std::list< int >  cpu_list  ) 
 

constructor

Parameters:
cpu_list stl list containing all cores the object has to care about

CPUFreq_Interface::~CPUFreq_Interface  )  [virtual]
 

destructor


Member Function Documentation

virtual int CPUFreq_Interface::adjustSpeed  )  [pure virtual]
 

adjusts speeds

Returns:
  • -1 if speed has been decreased
  • 1 if speed has been increased
  • 0 if speed has not been modified

Implemented in CPUFreq_Userspace, and CPUFreq_Kernel.

CPUFREQ_MODE CPUFreq_Interface::getMode  ) 
 

get current cpufreq policy

Returns:
CPUFREQ_MODE

virtual bool CPUFreq_Interface::init  )  [pure virtual]
 

checks if current cpu_id has a cpufreq directory and that it is no symlink

Returns:
true on success, false on error

Implemented in CPUFreq_Userspace, and CPUFreq_Kernel.

bool CPUFreq_Interface::read_line const char *  filename,
char *  line,
unsigned  len
[static]
 

read a line from a file

Parameters:
filename the filename to read from
line char pointer to store the read line
len chars to read
Returns:
false on error

unsigned CPUFreq_Interface::read_value const char *  filename  )  [static, protected]
 

read an integer value from a file

Parameters:
filename filename to read from
Returns:
the value read or 0 on error

virtual bool CPUFreq_Interface::readFrequencies  )  [pure virtual]
 

reads out frequencies

Returns:
false on error

Implemented in CPUFreq_Userspace, and CPUFreq_Kernel.

virtual void CPUFreq_Interface::reinitSpeed  )  [pure virtual]
 

reinits speeds

function for suspend workaround. after resuming the frequency might have changed and we haven't recognized. This could possibly break old PowerNow! machines, but as far as I know jumping more than one frequency at once is fixed in kernel module for that machines

Implemented in CPUFreq_Userspace, and CPUFreq_Kernel.

virtual void CPUFreq_Interface::setConfig  )  [pure virtual]
 

set configuration in initialize values

Implemented in CPUFreq_Userspace, and CPUFreq_Kernel.

void CPUFreq_Interface::setConfigs int  high_cpu,
int  max_limit,
int  hysters,
int  consider_nice
 

Update configs and apply them.

Parameters:
high_cpu increase frequency if CPU load exceeds this value
max_limit directly jump to the highest available frequency if the difference between CPU Load and last measured CPU load exceeds this value (only valid for userspace governor
hysters hysteresis value to not oscillate between two frequencies if CPU Load does not change createHysteresisArray()
consider_nice consider niced processes values as CPU load or not

int CPUFreq_Interface::setGovernor const std::string &  new_governor  ) 
 

set a ne cpufreq governor

int CPUFreq_Interface::setMode CPUFREQ_MODE  mode  ) 
 

set the current cpufreq policy

_PERFORMANCE, _DYNAMIC, _POWERSAVE

Parameters:
mode CPUFREQ_MODE
Returns:
  • 0 on success
  • -1 on failure
Always test the return value as the kernel class might loose the powersave or performance governor

If the call fails the cpufreq classes are destroyed, isSupported will return false and you must not call any CPUFreq functions any more (in fact these calls should be just ignored, but better be careful)

bool CPUFreq_Interface::write_line const char *  filename,
const char *  fmt,
  ...
[static]
 

write a line to a file

Parameters:
filename the filename to read from
fmt format to write
... variable argument list to write
Returns:
false on error


Member Data Documentation

int CPUFreq_Interface::_consider_nice [protected]
 

if niced processes should also count

not all of those work with "kernel" methods.

std::list< int > CPUFreq_Interface::_cpu_cores [protected]
 

list holding all cores which are affected by this interface

int CPUFreq_Interface::_cpu_hysteresis [protected]
 

value avoiding constant up/down switching

int CPUFreq_Interface::_cpu_max [protected]
 

value specifying when to switch up

int CPUFreq_Interface::_high_cpu_limit [protected]
 

if the load difference is higher than this go directly for full speed

CPUFREQ_MODE CPUFreq_Interface::_mode [protected]
 

stores the current cpufreq policy

(powersave, performance, dynamic)

string CPUFreq_Interface::AVAILABLE_FREQS_FILE [protected]
 

file containing available frequencies

string CPUFreq_Interface::GOVERNOR_FILE [protected]
 

file where active governor is in

string CPUFreq_Interface::MAX_SPEED_FILE [protected]
 

file containing the maximum freq

string CPUFreq_Interface::MIN_SPEED_FILE [protected]
 

file containing the minimum freq


The documentation for this class was generated from the following files:
Generated on Mon Mar 27 09:27:19 2006 for Powersave Daemon by  doxygen 1.4.6