Data Structures | Functions

CPU interface

Data Structures

struct  sa_cpu

Functions

SA_EXPORT int sa_open_cpu (void)
SA_EXPORT int sa_close_cpu (void)
SA_EXPORT int sa_count_cpus (uint16_t *number)
SA_EXPORT int sa_get_cpu (uint16_t index, struct sa_cpu *dst)
 Retrieves statistics from a given cpu index. This data is an average calculated since last time it was retrieved. If it was never calculated before it makes an average of the entire life of the cpu.
SA_EXPORT int sa_get_cpus (struct sa_cpu *dst, uint16_t dst_size, uint16_t *written)
 Retrieves statistics from as many processors as possible. The data of each cpu is an average calculated since last time it was retrieved. If it was never calculated before it makes an average of the entire life of the cpu.

Function Documentation

SA_EXPORT int sa_open_cpu ( void   ) 

Prepares the resources needed for retrieving cpu statistics. This function exists (and is needed) only when SA_OPEN_CPU is defined.

Returns:
If successful 0 is returned, otherwise an error code is returned. If the operative system is not supported the return value will be ENOTSUP.
See also:
sa_close_cpu()
SA_EXPORT int sa_close_cpu ( void   ) 

This function closes the resources used for retrieving cpu statistics. You should call it even when there was a previous error in another function of this API. This function exists (and is needed) only when SA_CLOSE_CPU is defined.

Returns:
If successful 0 is returned, otherwise an error code is returned.
See also:
sa_open_cpu()
SA_EXPORT int sa_count_cpus ( uint16_t *  number  ) 

Gives the number of processors that you can take statistics from.

Parameters:
number If the underlying platform does not support per-process stats this number will be 1 (even when there are many real CPUs). See the cpu matrix for further information.
Returns:
If successful 0 is returned, otherwise an error code is returned.
SA_EXPORT int sa_get_cpu ( uint16_t  index,
struct sa_cpu dst 
)

Retrieves statistics from a given cpu index. This data is an average calculated since last time it was retrieved. If it was never calculated before it makes an average of the entire life of the cpu.

Parameters:
index The cpu index. The first index value is 0.
dst Where the statistics will be stored.
Returns:
If successful 0 is returned, otherwise an error code is returned. ENODEV is returned when the requested cpu index was out of range.
SA_EXPORT int sa_get_cpus ( struct sa_cpu dst,
uint16_t  dst_size,
uint16_t *  written 
)

Retrieves statistics from as many processors as possible. The data of each cpu is an average calculated since last time it was retrieved. If it was never calculated before it makes an average of the entire life of the cpu.

Parameters:
dst A buffer where the statistics will be stored.
dst_size The number of cpus that fits in the dst buffer. If it's not big enough dst will be filled but ENOMEM will be returned.
written The amount of cpu statistics written.
Returns:
If successful 0 is returned, otherwise an error code is returned.
 All Data Structures Variables