/* * Detect whether a CPU is online * * Returns: * 1 -> if CPU is online * 0 -> if CPU is offline * negative errno values in error case
*/ int cpupower_is_cpu_online(unsignedint cpu)
{ char path[SYSFS_PATH_MAX]; int fd;
ssize_t numread; unsignedlonglong value; char linebuf[MAX_LINE_LEN]; char *endp; struct stat statbuf;
/* * Returns amount of cpus, negative on error, cpu_top must be * passed to cpu_topology_release to free resources * * Array is sorted after ->cpu_smt_list ->pkg, ->core
*/ int get_cpu_topology(struct cpupower_topology *cpu_top)
{ int cpu, last_pkg, cpus = sysconf(_SC_NPROCESSORS_CONF); char path[SYSFS_PATH_MAX]; char *last_cpu_list;
/* Count the number of distinct cpu lists to get the physical core * count.
*/
qsort(cpu_top->core_info, cpus, sizeof(struct cpuid_core_info),
__compare_core_cpu_list);
/* Count the number of distinct pkgs values. This works because the primary sort of the core_info struct was just
done by pkg value. */
last_pkg = cpu_top->core_info[0].pkg; for(cpu = 1; cpu < cpus; cpu++) { if (cpu_top->core_info[cpu].pkg != last_pkg &&
cpu_top->core_info[cpu].pkg != -1) {
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.