libdvfs  2.0
A light library to set CPU governor and freqency
Data Structures | Functions
dvfs_unit.h File Reference

Structures and functions related to DVFS units (group of cores running at the same frequency). More...

Go to the source code of this file.

Data Structures

struct  dvfs_unit
 A DVFS unit. More...
 

Functions

int dvfs_unit_open (dvfs_unit **ppUnit, unsigned int nb_cores, dvfs_core **cores, unsigned int unit_id)
 Creates a new DVFS unit in charge of the provided cores. More...
 
int dvfs_unit_close (dvfs_unit *unit)
 Frees the memory associated to a DVFS unit and restore their DVFS state. More...
 
int dvfs_unit_set_gov (const dvfs_unit *unit, const char *gov)
 Sets a governor on all the cores we are in charge of. More...
 
int dvfs_unit_set_freq (const dvfs_unit *unit, unsigned int freq)
 Sets the given frequency on all the unit cores. More...
 
int dvfs_unit_get_nb_cores (const dvfs_unit *unit, unsigned int *pNbCores)
 Gets te number of cores available in this DVFS unit. More...
 
int dvfs_unit_get_core (const dvfs_unit *unit, dvfs_core **ppCore, unsigned int id)
 Gets the core with the given id if it is part of this DVFS unit, or NULL otherwise. More...
 
int dvfs_unit_get_freq (const dvfs_unit *unit, unsigned int *pFreq)
 Gets the frequency currently set for the current DVFS unit. More...
 
int dvfs_unit_get_id (const dvfs_unit *unit, unsigned int *pID)
 Returns the index of the considered DVFS unit as stored in the corresponding DVFS context structure array. More...
 

Detailed Description

Structures and functions related to DVFS units (group of cores running at the same frequency).

See also
dvfs_core

Function Documentation

int dvfs_unit_close ( dvfs_unit unit)

Frees the memory associated to a DVFS unit and restore their DVFS state.

You are not supposed to directly call this function; use rather dvfs_stop(). It calls

See also
dvfs_core_close() on every
dvfs_core avaiable in this unit.
Parameters
unitThe DVFS unit to close.
Returns
Return values
DVFS_SUCCESSif everything goes right.
DVFS_ERROR_INVALID_ARGif unit or cores are NULL.
See also
dvfs_unit_open()
int dvfs_unit_get_core ( const dvfs_unit unit,
dvfs_core **  ppCore,
unsigned int  id 
)

Gets the core with the given id if it is part of this DVFS unit, or NULL otherwise.

Parameters
unitThe DVFS unit.
ppCorethe
See also
dvfs_core identified by id
Parameters
idThe core id.
Returns
Return values
DVFS_SUCCESSif everything goes right.
DVFS_ERROR_INVALID_ARGif unit or ppCore are NULL.
DVFS_ERROR_INVALID_CORE_IDthe id did not match any core.
int dvfs_unit_get_freq ( const dvfs_unit unit,
unsigned int *  pFreq 
)

Gets the frequency currently set for the current DVFS unit.

Parameters
unitThe DVFS unit.
pFreqthe frequency currently set for the current DVFS unit.
Returns
Return values
DVFS_SUCCESSif everything goes right.
DVFS_ERROR_INVALID_ARGif unit or pFreq are NULL.
int dvfs_unit_get_id ( const dvfs_unit unit,
unsigned int *  pID 
)

Returns the index of the considered DVFS unit as stored in the corresponding DVFS context structure array.

Parameters
unitThe DVFS unit.
pIDthe index of this DVFS unit.
Returns
Return values
DVFS_SUCCESSif everything goes right.
DVFS_ERROR_INVALID_ARGif unit or pID are NULL.
int dvfs_unit_get_nb_cores ( const dvfs_unit unit,
unsigned int *  pNbCores 
)

Gets te number of cores available in this DVFS unit.

Parameters
unitThe DVFS unit.
pNbCoresWill be filled with the number of cores.
Returns
Return values
DVFS_SUCCESSif everything goes right.
DVFS_ERROR_INVALID_ARGif unit or ppCore are NULL.
int dvfs_unit_open ( dvfs_unit **  ppUnit,
unsigned int  nb_cores,
dvfs_core **  cores,
unsigned int  unit_id 
)

Creates a new DVFS unit in charge of the provided cores.

You are not supposed to directly call this function, use rather dvfs_start().

Parameters
ppUnitpointer where the DVFS Unit instance will be placed
nb_coresThe number of cores the unit handles.
coresThe array of cores to handle. The array itself is freed when calling dvfs_unit_close().
unit_idthe ID of this DVFS unit.
Returns
Return values
DVFS_SUCCESSif everything goes right.
DVFS_ERROR_INVALID_ARGif ppUnit or cores are NULL.
DVFS_ERROR_MEM_ALLOC_FAILEDif memory allocation failed.
See also
dvfs_unit_close()
dvfs_core
int dvfs_unit_set_freq ( const dvfs_unit unit,
unsigned int  freq 
)

Sets the given frequency on all the unit cores.

The effect is unknown if the current governor is not "userspace".

Parameters
unitThe DVFS unit.
freqThe frequency to set.
Returns
Return values
DVFS_SUCCESSif everything goes right.
DVFS_ERROR_INVALID_ARGif unit is NULL.
int dvfs_unit_set_gov ( const dvfs_unit unit,
const char *  gov 
)

Sets a governor on all the cores we are in charge of.

Parameters
unitThe DVFS unit.
govThe governor to set.
Returns
Return values
DVFS_SUCCESSif everything goes right.
DVFS_ERROR_INVALID_ARGif unit or gov are NULL.