kvm_getcptime(3)

kvm_getcptime3

Fetch global cpu time statistics

Usage

#include <sys/param.h>

#include <sys/resource.h>

#include <sys/sysctl.h>

#include <kvm.h>

int

kvm_getcptime(kvm_t *kd, long *cp_time);

Library

Kernel Data Access Library (libkvm, -lkvm)

Overview

The kvm_getcptime() function stores the global CPU time statistics from the kernel kd in the array of counters pointed to by cp_time. Note that cp_time should point to an array of CPUSTATES long integers. The format of the counters is identical to that output by the kern.cp_time sysctl.

Caching

This function caches the nlist values for various kernel variables which it reuses in successive calls. You may call the function with kd set to NULL to clear this cache.

Return values

The kvm_getcptime function returns 0 on success and -1 on failure. If an error occurs, then an error message may be retrieved via kvm_geterr(3).

Releases

43 releases since FreeBSD 7.1-RELEASE; the text changed 29 times.

  1. 7.1
  2. 7.2
  3. 7.3
  4. 7.4
  5. 8.0
  6. 8.1
  7. 8.2
  8. 8.3
  9. 8.4
  10. 9.0
  11. 9.1
  12. 9.2
  13. 9.3
  14. 10.0
  15. 10.1
  16. 10.2
  17. 10.3
  18. 10.4
  19. 11.0
  20. 11.1
  21. 11.2
  22. 11.3
  23. 11.4
  24. 12.0
  25. 12.1
  26. 12.2
  27. 12.3
  28. 12.4
  29. 13.0–13.2
  30. 13.3–16.0

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.