LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (http://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   how to calculate total cpu time of task in percentage using task_struct (http://www.linuxquestions.org/questions/linux-kernel-70/how-to-calculate-total-cpu-time-of-task-in-percentage-using-task_struct-721316/)

namit2010 04-24-2009 12:19 AM

how to calculate total cpu time of task in percentage using task_struct
 
Hi all,

with the 2 fields of task_struct stucture, utime and stime i am calculating total time a task taken,

The procedure i m following in every 100th timer interrupt, I am updating cpu time of current task
(now_cpu - previous_cpu)/(now_jiffies -prev_jiffeis)

now_cpu = (utime+stime);

but i am not satisfied with the result,any one have idea about that
please help me out.

geek745 05-25-2009 12:43 AM

Still having problems with that one? Your approach looks good. You might want to only measure before and after the task because your computation of the time it takes to complete is itself adding to the time.


All times are GMT -5. The time now is 06:36 PM.