Re: division and cpu usage

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Aug 28 2007 12:41, Luka Napotnik wrote:
>
>How about this:
>===============================
>old_stime = task->stime;
>old_utime = task->utime
>old_j = jiffies;
>
>set_current_state(TASK_INTERRUPTIBLE);
>schedule_timeout(1 * HZ);
>
>new_stime = task->stime;
>new_utime = task->utime;
>new_j = jiffies;
>sum = ((new_stime - old_stime) + (new_utime - old_utime)) * 100 / (new_j
>- old_j)
>===============================
>
>I get how much time the task has spent in 1 sec in the scheduler and
>then get the percentage?

Looks sane to me. Though you have to try. And, like I said before, be aware of
dynticks, so you might want to use something else than jiffies. Not sure what
the function was called though.

	Jan
-- 
-
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/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux