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 04-27-2010, 11:30 PM   #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, 01:19 AM   #2
mzsade
Member
 
Registered: Sep 2009
Distribution: Linux Mint 9, Linux Mint 17.2(xfce), LMDE2(Mate), Debian Jessie minimal (with standalone OBox)
Posts: 299

Rep: Reputation: 34
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 Thumbnails
Click image for larger version

Name:	Screenshot - Monday 26 April 2010 - 01:13:58  IST.png
Views:	44
Size:	113.9 KB
ID:	3456  

Last edited by mzsade; 04-28-2010 at 01:28 AM. Reason: forgot tags
 
Old 04-28-2010, 01: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, 02:39 AM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
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, 03: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, 05:00 PM   #6
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
"man proc" - then "/\/stat" (no quotes) will get you to the data of interest.
 
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 utilisation on Xorg when fsck is running aeternitas Linux - Software 2 04-20-2010 01:26 AM
[SOLVED] High cpu utilisation for X process in -current rpedrica Slackware 4 09-21-2009 09:08 AM
How can you force a program/process to run on a specific CPU core? icedfusion Linux - Newbie 2 12-31-2008 10:10 AM
Getting core id, physical id of running process debrajde Linux - Hardware 1 07-29-2007 03:17 AM
Getting core id, physical id of running process debrajde Programming 0 07-28-2007 11:22 PM

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

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