Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Linux - Kernel This forum is for all discussion relating to the Linux kernel.


  Search this Thread
Old 04-23-2009, 11:19 PM   #1
LQ Newbie
Registered: Apr 2009
Posts: 5

Rep: Reputation: 0
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.
Old 05-24-2009, 11:43 PM   #2
Registered: Jul 2004
Location: Boston, MA
Distribution: Slackware; Ubuntu; Slax
Posts: 172
Blog Entries: 2

Rep: Reputation: 34
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.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculate total number of mailq items a1phanumeric Linux - Newbie 1 11-15-2007 11:29 AM
I/O wait CPU percentage definition DotHQ Linux - Enterprise 9 07-27-2007 01:36 AM
How to calculate the total RAM used by several processes rjlee Linux - Software 3 07-19-2007 05:33 PM
I don't understand how to calculate the total value of (ls -l) greeting Linux - General 7 08-12-2006 05:28 AM
find remaining percentage of cpu happy78 Programming 11 09-26-2005 08:02 PM > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 02:03 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration