问题
Is there any way i can get the CPU which CPU the process is running?
回答1:
You can use /proc/[id]/stat
file and read the 39th value (seperated by spaces). This tells which cpu id the process of [pid] is currently running on:
cat /proc/[id]/stat | awk '{print $39}'
For more info: man proc.
回答2:
If you wanna get it in code, it is the variable current points to.
回答3:
You can use "ps" command as:
You can use "ps" command as:
ps -p <pid> -o pid,comm,psr
Ex:
ps -p 1 -o pid,comm,psr
PID COMMAND PSR
1 init 10
来源:https://stackoverflow.com/questions/8131320/finding-processor-id-in-which-process-is-running-through-command-interface-simi