Reputation: 1063
I have a multi thread c++ programming and using cpu affinity to lock different different threads into different cpus.
But how can I check which process is running on which cpu?
By "top", I can only see those processes. Like PID xxxx is running on CPU 5
THanks
Upvotes: 3
Views: 1671
Reputation: 1063
Find the easiest solution: top, then f, then j, then enter. Now I have the core for each process with top.
Upvotes: 2
Reputation: 50034
On Linux, you find this information in the proc
filesystem. For each thread, there is a file with the following name in the filesystem:
/proc/<pid>/task/<tid>/stat
The column 39 contains the CPU number the thread was last executed on. See the following man page for more information:
Upvotes: 2