how to know which cpu current process run

loody miloody at
Thu Aug 15 09:28:45 EDT 2013

hi Valdis:
Thanks for your kind reply :)
2013/8/15  <Valdis.Kletnieks at>:
> On Thu, 15 Aug 2013 20:24:21 +0800, loody said:
>> is there any shell command or tool can let me know which cpu current
>> process run on?
> Why are you trying to check from the shell?  What problem are you
> trying to solve by knowing which CPU?
I adopt one sample code which uses sched_setaffinity to force user
program running on core#1, suppose my environment has core#0 and

Theoretically, it is ONLY run on core#1.
When I use top, I cannot tell whether it runs on core#0 or core#1, so
I wrote this letter to ask help any tool checking what cpu this
program ran on.
i also attach my program for all your reference.

>And checking the *current* process tells you even less than "checking the
>process you care about" - because unless it's a shell builtin, when you
>launch the command, it will quite possibly end up on some core other than
>the one the shell is running on....

it seems I use wrong way to express what I need.
I need any tool to check whether the process I assigned to cpu with
sched_setaffinity  did work.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: affinity.sample.c
Type: text/x-csrc
Size: 1281 bytes
Desc: not available
Url : 

More information about the Kernelnewbies mailing list