KVM_GETCPTIME(3)
πΈ NAME πΈ
kvm_getcptime β fetch global CPU time statistics π
okay so this is the manual page for KVM_GETCPTIME(3) from the Library Functions Manual, and it's literally all about grabbing the global CPU time stats. slay.
π LIBRARY π
Kernel Data Access Library (libkvm, -lkvm) π«Ά
β¨ SYNOPSIS β¨
bestie, you're gonna need these includes and then the function call:
#include <sys/param.h>
#include <sys/resource.h>
#include <sys/sysctl.h>
#include <kvm.h>
int
kvm_getcptime(kvm_t *kd, long *cp_time);
π DESCRIPTION π
The kvm_getcptime() function stores the global CPU time statistics from the kernel kd into the array of counters that cp_time points to. π
tiny but important note:cp_timeshould point to an array ofCPUSTATESlongintegers. no cap.
The format of those counters is identical to the output from the kern.cp_time sysctl. iconic.
π§ CACHING π§
This function caches the nlist values for various kernel variables and reuses them in successive calls. lowkey efficient. β¨
You may call the function with kd set to NULL to clear this cache. yep, that's the reset-button vibe.
π RETURN VALUES π
The kvm_getcptime function returns 0 on success and -1 on failure. periodt.
If an error occurs, then an error message may be retrieved via kvm_geterr(3). so if things go sideways, that's where you look π.
π¦ SEE ALSO π¦
cute little sign-off: this page is from Debian, dated August 19, 2008, and it's the KVM_GETCPTIME(3) manual page π byeee!
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (c) 2008 Yahoo!, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms