machine: add variable CPU poll.

This commit is contained in:
Alastair Poole 2020-06-24 23:10:50 +01:00
parent 908721a720
commit 8a100e0bbf
2 changed files with 11 additions and 2 deletions

View File

@ -352,7 +352,7 @@ _cpu_state_get(cpu_core_t **cores, int ncpu)
}
cpu_core_t **
system_cpu_usage_get(int *ncpu)
system_cpu_usage_delayed_get(int *ncpu, int usecs)
{
cpu_core_t **cores;
int i;
@ -365,12 +365,18 @@ system_cpu_usage_get(int *ncpu)
cores[i] = calloc(1, sizeof(cpu_core_t));
_cpu_state_get(cores, *ncpu);
usleep(1000000);
usleep(usecs);
_cpu_state_get(cores, *ncpu);
return cores;
}
cpu_core_t **
system_cpu_usage_get(int *ncpu)
{
return system_cpu_usage_delayed_get(ncpu, 1000000);
}
#if defined(__linux__)
static unsigned long
_meminfo_parse_line(const char *line)

View File

@ -84,6 +84,9 @@ system_cpu_online_count_get();
cpu_core_t **
system_cpu_usage_get(int *ncpu);
cpu_core_t **
system_cpu_usage_delayed_get(int *ncpu, int usecs);
void
system_memory_usage_get(meminfo_t *memory);