how to calculate total cpu time of task in percentage using task_struct
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.
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 01:56 PM.|