CpufreqManagement Class Reference

class caring about all cpus More...

#include <cpufreq_management.h>

List of all members.

Public Member Functions

 CpufreqManagement ()
 constructor
 ~CpufreqManagement ()
 destructor
void init ()
 creates the cpufreq objects for each base cpu
bool isSupported ()
 This can be called outside after calling createCPUFreqObject().
void adjustSpeeds ()
 adjusts the speeds of all CPUs to their load (if in dynamic mode)
int setModes (CPUFREQ_MODE mode, EventManagement *eM)
 set cpufreq policy for all CPUs
CPUFREQ_MODE getMode ()
 get the current cpu policy
void reinitSpeeds ()
 This function can be used if the userspace class thinks it run out of sync, what means it has another frequency stored that actually is active. IIRC this has been used after suspend, but should be obsolute. The same for the according reinitSpeed function.
void rereadFrequencies ()
 Reinitialises speeds. This function should be called if the frequencies could change unnoticably (e.g. after supsend, AC events, ...) This funcion should only be called if the userspace class is used.
int setGovernors (const string &new_governor)
 set the governor on all CPUs
void setConfigs ()
 set configs of all cpus
CPUFREQ_CONTROL_MODE controlMode ()
 get the current control mode used
int enableCPU (int cpu)
 enables a CPU
int disableCPU (int cpu)
 disables a CPU
bool hasControlMode (CPUFREQ_CONTROL_MODE control_mode)
 check if all cpufreq objects contain a control mode

Private Member Functions

bool initSingleInterface (std::list< int > &cores, CPUFREQ_CONTROL_MODE control_mode)
 inits one single cpufreq interface
bool getCoresAffectedCpus (std::list< std::list< int > > &cpu_list, int num_cpus)
 get cpu cores which belong together via the affectec_cpus file
bool getCoresProcfile (list< list< int > > &cpu_list, int num_cpus)
 get cpucores which belong together via parsing /proc/cpuinfi
bool readCpu (std::list< int > &core_list, int cpu)
 split up the given cpu in its siblings
bool siblingExists (list< int > core_list, int core)
 check whether the given list contains the given core
void checkCPUHotplug ()
 checks CPU hotplugging depending on the scheme

Private Attributes

std::list< CPUFreq_Interface * > _cpufreq_objects
 stl list holding all cpufreq objects
std::list< std::list< int > > _cpus
 stl list holding all cpus
int _control_modes
 bitmask containin control modes used
CPUFREQ_CONTROL_MODE _initial_control_mode
 default control mode
int _initial_cpu_count
 number of CPUs on startup


Detailed Description

class caring about all cpus


Constructor & Destructor Documentation

CpufreqManagement::CpufreqManagement  ) 
 

constructor

CpufreqManagement::~CpufreqManagement  ) 
 

destructor


Member Function Documentation

void CpufreqManagement::adjustSpeeds  ) 
 

adjusts the speeds of all CPUs to their load (if in dynamic mode)

void CpufreqManagement::checkCPUHotplug  )  [private]
 

checks CPU hotplugging depending on the scheme

CPUFREQ_CONTROL_MODE CpufreqManagement::controlMode  ) 
 

get the current control mode used

Returns:
CPUFREQ_CONTROL_MODE

int CpufreqManagement::disableCPU int  cpu  ) 
 

disables a CPU

Parameters:
cpu CPU to disable starting from 0
Returns:
CPUFreq_Interface::enable()

int CpufreqManagement::enableCPU int  cpu  ) 
 

enables a CPU

Parameters:
cpu CPU to disable starting from 0
Returns:
CPUFreq_Interface::enable()

bool CpufreqManagement::getCoresAffectedCpus std::list< std::list< int > > &  cpu_list,
int  num_cpus
[private]
 

get cpu cores which belong together via the affectec_cpus file

Parameters:
cpu_list list containing list of cpus
num_cpus number of cores in system
the given list is something like

sockel 0 -------> core 0 | |----> core 1 | ... sockel 1 -------> core 0 | |----> core 1 | ...

Returns:
true if dependencies could be fugured out, false otherwise

bool CpufreqManagement::getCoresProcfile list< list< int > > &  cpu_list,
int  num_cpus
[private]
 

get cpucores which belong together via parsing /proc/cpuinfi

this function is kept to get cpufreq and multicores working with older kernels. It should not be needed with a kernel > 2.6.13

Parameters:
cpu_list stl list containing list of cpus
num_cpus number of cores in system
Returns:
true if dependencies could be fugured out, false otherwise

CPUFREQ_MODE CpufreqManagement::getMode  ) 
 

get the current cpu policy

Returns:
the current cpu policy

bool CpufreqManagement::hasControlMode CPUFREQ_CONTROL_MODE  control_mode  ) 
 

check if all cpufreq objects contain a control mode

void CpufreqManagement::init  ) 
 

creates the cpufreq objects for each base cpu

bool CpufreqManagement::initSingleInterface std::list< int > &  cores,
CPUFREQ_CONTROL_MODE  control_mode
[private]
 

inits one single cpufreq interface

this function tries to initialize a cpufreq interface, either kernel or userspace. If kernel does not work, it falls back to a userspace object

Parameters:
cores list of cores this interface has to care for
control_mode CPUFREQ_CONTROL_MODE
Returns:
false if neither interface could be set up

bool CpufreqManagement::isSupported  ) 
 

This can be called outside after calling createCPUFreqObject().

Returns:
true if supported

bool CpufreqManagement::readCpu std::list< int > &  core_list,
int  cpu
[private]
 

split up the given cpu in its siblings

Parameters:
core_list stl list of cores which gets filled
cpu cpu number starting with 0
Returns:
false on error, true on succes

void CpufreqManagement::reinitSpeeds  ) 
 

This function can be used if the userspace class thinks it run out of sync, what means it has another frequency stored that actually is active. IIRC this has been used after suspend, but should be obsolute. The same for the according reinitSpeed function.

Todo:
: Delete this one if running stable

void CpufreqManagement::rereadFrequencies  ) 
 

Reinitialises speeds. This function should be called if the frequencies could change unnoticably (e.g. after supsend, AC events, ...) This funcion should only be called if the userspace class is used.

void CpufreqManagement::setConfigs  ) 
 

set configs of all cpus

int CpufreqManagement::setGovernors const string &  new_governor  ) 
 

set the governor on all CPUs

int CpufreqManagement::setModes CPUFREQ_MODE  mode,
EventManagement eM
 

set cpufreq policy for all CPUs

Parameters:
mode the new mode to set
eM object to throw apporpriate events

bool CpufreqManagement::siblingExists list< int >  core_list,
int  core
[private]
 

check whether the given list contains the given core

Parameters:
core_list list holding alrady added cores
core core to check whether it is in core_list
Returns:
true if already inside core_list, false otherwise


Member Data Documentation

int CpufreqManagement::_control_modes [private]
 

bitmask containin control modes used

std::list< CPUFreq_Interface* > CpufreqManagement::_cpufreq_objects [private]
 

stl list holding all cpufreq objects

std::list< std::list< int > > CpufreqManagement::_cpus [private]
 

stl list holding all cpus

CPUFREQ_CONTROL_MODE CpufreqManagement::_initial_control_mode [private]
 

default control mode

needed to check whether we automatically switched to userspace if kernel does not work. On scheme switch, we need this as reference whether the settings for the control mode changed.

int CpufreqManagement::_initial_cpu_count [private]
 

number of CPUs on startup


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