LinuxQuestions.org

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

namit2010 04-23-2009 11:19 PM

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-24-2009 11:43 PM

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 02:34 PM.