Tuesday, February 6, 2024

[SOLVED] how to print all the processes listed on one particular core of the Processor in Linux?

Issue

I would like to write a small program which will ask me the core(or CPU) number and would list out all the currently executing processes on that particular entered core.

for example,

output would be something like this,

Enter the CPU(or Core) Number : 1

process 1, process 2, process 3, ...... So On.

Enter the CPU(or Core) Number : 2 or any valid core number

process 1, process 2, process 3, ...... So On.


Solution

The following article talks about the CPU utilities in linux

http://www.cyberciti.biz/tips/how-do-i-find-out-linux-cpu-utilization.html

For your case I believe you might try taskset like

# taskset -p <PID>

This may be useful to find the affinity of a particular process to the CPU.

There is this other article on csets (groups of CPUs for specific applications/processes) which is a little more organized than taskset - https://rt.wiki.kernel.org/index.php/Cpuset_management_utility/tutorial



Answered By - Sameer Niphadkar
Answer Checked By - Mary Flores (WPSolving Volunteer)