LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
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 04-28-2010, 12:30 AM   #1
chamila1986
Member
 
Registered: Oct 2009
Posts: 31

Rep: Reputation: 15
Unhappy Get process running CPU core and the utilisation on that core...


Dear Sir,Madom,
Assume someone bind a particular process to a particular CPU core(In multi core machine) by using sched_setaffinity() like functions. Then how we can get that process running core id and CPU core utilisation of that process on that running CPU core(Pragmatically or by a Linux command)?. Any ideas please. Thank you.
 
Old 04-28-2010, 02:19 AM   #2
mzsade
Member
 
Registered: Sep 2009
Distribution: Linux Mint 9, Crunchbang Linux 10
Posts: 77

Rep: Reputation: 20
Top cpu processes, system information

Install conky, if possible on your system, from synaptic. You can then change the ~/.conkyrc to suit you. Mine gives something like the text on the right in the Screenshot.

To get list of all running processes and their IDs run "ps -x" in the terminal.
Attached Images
File Type: png Screenshot - Monday 26 April 2010 - 01:13:58 IST.png (113.9 KB, 15 views)

Last edited by mzsade; 04-28-2010 at 02:28 AM. Reason: forgot tags
 
Old 04-28-2010, 02:42 AM   #3
chamila1986
Member
 
Registered: Oct 2009
Posts: 31

Original Poster
Rep: Reputation: 15
Question

Dear Sir mzsade,
I need to get process running core id and CPU core utilisation to my own 'C' program... I'm stuck....
 
Old 04-28-2010, 03:39 AM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,497

Rep: Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077
Have a look in /proc/<pid>/stat
That will give you the number of jiffies used over a period - you'll have to calculate the percentage(s) yourself. If the process is bound to a particular processor, the "last used CPU" will always be the same.
Another option is to use cgroups and use the accounting that provides - documentation in the (kernel) source tree.
 
1 members found this post helpful.
Old 04-28-2010, 04:13 PM   #5
chamila1986
Member
 
Registered: Oct 2009
Posts: 31

Original Poster
Rep: Reputation: 15
Question

Dear sir,

I get the file using,
Code:
$cat /proc/8876/stat
I got the output as,

Code:
8876 (BindMe) S 3303 8876 1680 0 -1 4194304 630 0 0 0 3 4 0 0 20 0 5 0 1727730 35446784 181 4294967295 134512640 134528576 3217712768 3217712496 7271458 0 4 4096 0 4294967295 0 0 17 0 0 0 0 0 0
So which value indicates the last used CPU?

PS: Can u give me the field names of these values(Any reference)?
(I referred http://lkml.org/lkml/2007/5/31/437. If u know a good reference please be kind enough to inform it to me.)
 
Old 04-28-2010, 06:00 PM   #6
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,497

Rep: Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077
"man proc" - then "/\/stat" (no quotes) will get you to the data of interest.
 
1 members found this post helpful.
  


Reply


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
High CPU utilisation on Xorg when fsck is running aeternitas Linux - Software 2 04-20-2010 02:26 AM
[SOLVED] High cpu utilisation for X process in -current rpedrica Slackware 4 09-21-2009 10:08 AM
How can you force a program/process to run on a specific CPU core? icedfusion Linux - Newbie 2 12-31-2008 11:10 AM
Getting core id, physical id of running process debrajde Linux - Hardware 1 07-29-2007 04:17 AM
Getting core id, physical id of running process debrajde Programming 0 07-29-2007 12:22 AM


All times are GMT -5. The time now is 08:56 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration