On Wed, 2005-05-11 at 16:05 +0200, Alfred M. Szmidt wrote:
> - I can't find a way to get statistics about CPU usage
> (user/sys/kernel times, etc.), i.e. what you get in /proc/stat
> with Linux.
> Don't recall of hand, but you could look at see what GNU uptime does
> to get that info.
I've read its code (along with pptop, vmstat, and w, from which I took
most of the code, or the ideas, anyway). GNU uptime does not show
statistics about CPU usage, as far as I know. Or is it new? (I can't see
it in coreutils CVS)
> - I did not find a clean way to get the last running PID. That
> would mean getting a task id from Mach (since our scheduler is
> in Mach), and converting it to a proc_stat to get its pid, but
> I don't think Mach has interfaces for the first step.
> What do you mean by "the last running PID"?
Forget that. A #kernelnewbies log made me think that was the PID of the
last scheduled task, but it's the last allocated PID. I can get that
alright with libps.
> - We can't get the "idle time" along with the uptime like in
> /proc/uptime, but I'm not sure it matters anyway.
> Once again, see GNU uptime.
Again, I don't think it gets that value. idletime is computed like this
on Linux :
cputime_t idletime = cputime_add(init_task.utime,
utime is the time (in jiffies) spent in user space, stime spent in
kernel space (_S_yscalls). init_task is the task structure for init.
So that's the total time init is used (so, the idle time). Of course,
this way of computing idle time doesn't seem to be appropriate for
GNU/Hurd, so I've left it unimplemented (which is not very important
since libgtop2 makes you say what feature you've got for each port, and
uses only them).
> For the uptime you will need to use
> something like fetch_boot_time (see the Hurd source code for that
> function, somewhere in w.c).
Sure, I'm already familiar with it. It might be useful to add it in
libshouldbeinlibc (and ultimately in libc ;-) since it's the second time
I've had to use it in a port (ud was the first).
- From: Manuel Menal <email@example.com>
- Re: libgtop2
- From: "Alfred M. Szmidt" <firstname.lastname@example.org>