LinuxQuestions.org
Help answer threads with 0 replies.
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 02-03-2010, 10:06 PM   #1
chamila1986
Member
 
Registered: Oct 2009
Posts: 31

Rep: Reputation: 15
cpu core utilization


Can anyone explain the way that I can get the current cpu core utilization for each cpu core in multi core machine pragmatically(In C )...
 
Old 02-03-2010, 11:09 PM   #2
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Bookworm (Fluxbox WM)
Posts: 1,391
Blog Entries: 54

Rep: Reputation: 360Reputation: 360Reputation: 360Reputation: 360
A method is:

1. open /proc/stat
2. read in the idle (and perhaps iowait) times for each processor (see man /proc for a description of the format)
3. wait one second
4. read in the idle times again
5. find the differences and divide by the tick frequency

This will give you the idle fraction for each cpu over the last second.

Last edited by neonsignal; 02-03-2010 at 11:13 PM.
 
1 members found this post helpful.
  


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
High CPU utilization on only one CPU out of 4 CPUs makam.sreekanth Linux - Kernel 2 09-03-2009 04:12 AM
cpu utilization and cpu load soltanloo Linux - General 1 06-07-2009 02:19 AM
Linux desktop GUI tool for CPU utilization and bandwidth utilization karimasif Linux - Software 4 03-03-2008 01:09 PM
CPU utilization in 2.4 vs 2.6.. lynz Linux - Software 2 06-04-2007 01:40 PM
50% CPU utilization on AMD 64, with 64 bit Fedora Core 3 bh2005 Linux - Newbie 4 04-26-2005 08:15 AM

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

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