Messages in this thread | ![/](/images/icornerl.gif) | | Date | Sat, 18 Oct 2003 08:48:35 +1000 | From | Nick Piggin <> | Subject | Re: decaying average for %CPU |
| |
Albert Cahalan wrote:
>On Thu, 2003-10-16 at 23:21, Nick Piggin wrote: > > >>Albert Cahalan wrote: >> >> >>>On Thu, 2003-10-16 at 22:56, Nick Piggin wrote: >>> >>> >>>>Albert Cahalan wrote: >>>> >>>> >>>> >>>>>The UNIX standard requires that Linux provide >>>>>some measure of a process's "recent" CPU usage. >>>>>Right now, it isn't provided. You might run a >>>>>CPU hog for a year, stop it ("kill -STOP 42") >>>>>for a few hours, and see that "ps" is still >>>>>reporting 99.9% CPU usage. This is because the >>>>>kernel does not provide a decaying average. >>>>> >>>>> >>>>> >>>>I think the kernel provides enough info for userspace to do >>>>the job, doesn't it? >>>> >>>> >>>> >>>I'm pretty sure not. Linux provides: >>> >>>per-process start time >>>current time >>>per-process total (lifetime) CPU usage >>>units of time measurement (awkwardly) >>>boot time >>> >>> >>But your userspace program can calculate deltas in the total >>CPU statistics. Yep, its in /proc/stat. >> >> > >Huh? > >This isn't about "top", which displays % of CPU >time used over the refresh interval by reading >all the process data multiple times. > >This is about programs like "ps", which read >everything and then spit out the output. > >I hope you're not suggesting to read things >twice with a huge sleep(5) in the middle, or >to run some kind of daemon that polls /proc >once a second. That's far beyond horrid. > >
Yeah I spose it is.
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| ![\](/images/icornerr.gif) |