LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-26-2012, 11:04 AM   #1
DavidA
LQ Newbie
 
Registered: Aug 2011
Location: UK
Posts: 11

Rep: Reputation: Disabled
Question regarding /proc/stat (cpu load measurement)


Hi,

I am working on an embedded Linux project and need to measure cpu load programmatically. General advice seems to be to use /proc/stat for this purpose. I understand the algorithm to do that. However, I am confused by the results I am seeing.

I am running one user process and 'top' shows that it is consuming 12% of the cpu.

However, if I repeatedly execute 'cat /proc/stat' from the command line, the first number after 'cpu', which should be the number of 'user' jiffies, barely changes. The 'idle' value (4th number) does change appreciably.

Why is the 'user' value not changing?

Best regards

David
 
Old 11-26-2012, 02:19 PM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
As I understand it, the value shown by top is a percentage of the non-idle time, whereas the numbers you see in /proc/stat are absolute times.
--- rod.
 
  


Reply

Tags
linux, proc, programming



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
/proc/stat CPU utilization seems incorrect bassvdo Linux - Kernel 4 05-09-2012 04:20 AM
CPU usage from /proc/stat Rohan Nakar Linux - Newbie 3 01-25-2007 12:49 AM
New cpu values in /proc/stat? eldonz Linux - General 1 10-19-2005 12:16 PM
/proc/stat cpu info GDarkBladE Linux - Software 2 10-11-2005 03:16 PM
/proc/stat cpu ahz Programming 1 04-24-2005 07:24 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:17 PM.

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