CPU user/kernel time given the PID
Jay Loden
freebsd at jayloden.com
Sun Mar 8 07:20:07 PDT 2009
I'm working on FreeBSD support for a Python library called psutil for reading
process information in a cross-platform fashion. Each platform-specific module
is written in C, so the majority of the FreeBSD code is a C interface to various
process information. I've been having some trouble working out how to get CPU
user/kernel time for a given PID. I took a look at the source to top and ps but
neither really helped since they don't seem to cover the info I was looking for
(or I missed it).
I'm not sure if there's a better way to go about this but I've been looking at
sysctl and the kinfo_proc struct - is there somewhere more appropriate to
retrieve this information? If the kinfo_proc struct is the way to go, then do I
want to use ki_runtime, ki_swtime or something else, and does that mean there's
no distinction between user/kern time for a process? If anyone has code samples
or recommended docs to get me pointed in the right direction that would be great.
Thanks,
-Jay
More information about the freebsd-hackers
mailing list