How can I see which CPU core a thread is running in?

前端 未结 7 1250
悲&欢浪女
悲&欢浪女 2020-12-07 14:09

In Linux, supposing a thread\'s pid is [pid], from the directory /proc/[pid] we can get many useful information. For example, these proc files, /proc/[pid]/status,/proc/[pid

7条回答
  •  星月不相逢
    2020-12-07 14:24

    The threads are not necessary to bound one particular Core (if you did not pin it). Therefore to see the continuous switching of the core you can use (a modified answer of Dmitry):

    watch -tdn0.5 ps -mo pid,tid,%cpu,psr -p \`pgrep BINARY-NAME\`
    

    For example:

    watch -tdn0.5 ps -mo pid,tid,%cpu,psr -p \`pgrep firefox\`
    

提交回复
热议问题