LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 04-23-2009, 11:19 PM   #1
namit2010
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
geek745
Member
 
Registered: Jul 2004
Location: Alton, IL
Distribution: Linux Mint; 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.
 
  


Reply



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 09:22 AM.

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