All Data Structures Functions Variables Enumerations Enumerator Groups Pages
CPU interface

## Data Structures

struct | sa_cpu

## Functions

int | sa_open_cpu (void) SA_EXPORT
int | sa_close_cpu (void) SA_EXPORT
int | sa_reset_cpus () SA_EXPORT
int | sa_count_cpus (uint16_t *number) SA_EXPORT SA_NONNULL
int | sa_get_cpu (uint16_t index, struct sa_cpu *dst) SA_EXPORT SA_NONNULL
| 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_reset_cpus() should be called at least once before this function and everytime you need fresh values. More...
int | sa_get_cpus (struct sa_cpu *dst, uint16_t dst_size, uint16_t *written) SA_EXPORT SA_NONNULL
| 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. sa_reset_cpus() should be called at least once before this function and everytime you need fresh values. More...

## Detailed Description

## Function Documentation

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 operating system is not supported the return value will be ENOTSUP.

See Also
  sa_close_cpu()

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()

int sa_reset_cpus | ( | ) |  |

Refreshes the underlying operating system cache.

Returns
  If successful 0 is returned, otherwise an error code is returned.

Since
  0.6.0

int sa_count_cpus | ( | uint16_t * | number) |  |

Gives the number of processors that you can take statistics from. You don't need to call sa_reset_cpus() before this function.

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.

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_reset_cpus() should be called at least once before this function and everytime you need fresh values.

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.

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. sa_reset_cpus() should be called at least once before this function and everytime you need fresh values.

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.