Support LQ: Use code LQ3 and save $3 on Domain Registration
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-24-2009, 12:19 AM   #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-25-2009, 12:43 AM   #2
Registered: Jul 2004
Location: Boston, MA
Distribution: Slackware; Ubuntu; Slax
Posts: 172
Blog Entries: 2

Rep: Reputation: 33
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 12:29 PM
I/O wait CPU percentage definition DotHQ Linux - Enterprise 9 07-27-2007 02:36 AM
How to calculate the total RAM used by several processes rjlee Linux - Software 3 07-19-2007 06:33 PM
I don't understand how to calculate the total value of (ls -l) greeting Linux - General 7 08-12-2006 06:28 AM
find remaining percentage of cpu happy78 Programming 11 09-26-2005 09:02 PM

All times are GMT -5. The time now is 07:27 PM.

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