Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


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

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


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

Old 11-26-2012, 02:19 PM   #2
LQ 5k Club
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,397
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.


linux, proc, programming

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
/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 > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:18 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