On Aug 28 2007 00:07, Luka Napotnik wrote: >>>> 2. I'm trying to get the percentage of CPU used for a certain >>>> task_struct and figured the following formula: >>>> >>>> (task->utime + task->stime) / jiffies > >This formula just doesn't work. I have a task with 99% CPU (top) but the >result of that formula is random (4, sometimes 8). What am I doing >wrong? Please help.
You are calculating the CPU time the process has used since the start. That is definitely not the same as the "%CPU" that top shows, more like the "TIME+" top shows by default. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/