Go Job Hunting at the LQ Job Marketplace
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 09-17-2010, 04:28 PM   #1
LQ Newbie
Registered: Sep 2010
Posts: 1

Rep: Reputation: 0
How to find what task is running on a particular cpu core ?

Hello ,

I am using Kernel on an Intel Core2Duo based system.
1) I have to find on which core a particular task is running on .
2) I have to just log whenever my task is scheduled on any of the cores with the cpu core number & timestamp info.
I am ready to modify the kernel to do printk or some logging .
I guess there used to be 2 fields called 'processor' and 'last_processor' in task_struct in older kernels which probably had this information .

So what do I do to find out on which core a particular task is running on ?

Or ,

Are there any utilities that are simple-to-use and can display the tasks that are running on each of the cores , including the cpu core info ? top , mpstat etc do not tell you on which cpu core a task is running on .
Old 09-17-2010, 10:18 PM   #2
Registered: Feb 2008
Location: Texas
Distribution: Fedora, RHEL, CentOS
Posts: 488

Rep: Reputation: 78
top will, not by default, but if you add the field according to the man page on my system.

       j: P  --  Last used CPU (SMP)
          A number representing the last used processor.  In a true SMP  envi-
          ronment  this  will likely change frequently since the kernel inten-
          tionally uses weak affinity.  Also, the very act of running top  may
          break  this  weak  affinity  and cause more processes to change CPUs
          more often (because of the extra demand for cpu time).
user@system ~]$ top
Old 09-17-2010, 10:29 PM   #3
LQ Veteran
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 13,630

Rep: Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393
Simplest is to use /proc/<pid>/stat (which is where top is getting it from in all likelihood).
But as per above, this is "last processor" dispatched on. Given the way the scheduler attempts to keep tasks on the same processor, this should normally suffice.


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 On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Get process running CPU core and the utilisation on that core... chamila1986 Programming 5 04-28-2010 06:00 PM
How to find what core CPU is present? linuxunix Linux - Newbie 2 03-26-2010 04:18 AM
how to find on which cpu core linux kernel tasks are running zzfcpit0120 Linux - Kernel 1 10-16-2009 06:05 AM
userland: how to find the cpu currently running at aasa0001 Linux - Newbie 1 02-11-2009 05:14 AM
Strange noise while CPU is idle on Dell C600 running Fedora Core 1 theoldman Linux - Newbie 1 01-23-2004 07:47 PM

All times are GMT -5. The time now is 05:02 AM.

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