Linux进程bing指定CPU核/设置CPU亲和力三种方法

版权声明:转载请注明出处,多谢! https://blog.csdn.net/guo_lei_lamant/article/details/85605690

先记录一下,日后有时间补充。

  1. Linux shell方法:设置环境变量
    E.g: export GOMP_CPU_AFFINITY=4 //指定CPU核为4
    Reference: GOMP_CPU_AFFINITY – Bind threads to specific CPUs
  2. Linux shell方法:taskset
    E.g: tasket -p <PID> //查看进程号为PID的进程目前指定的CPU核
    taskset -pc 4,5 <PID> //给进程号为<PID>的进程指定CPU为4、5
  3. Code-Specile:
    Reference: Linux编程-让进程或线程运行在指定的CPU上
    上述链接中除了对绑定进程到指定CPU的讲解外,还有对绑定线程到指定CPU的讲解。

猜你喜欢

转载自blog.csdn.net/guo_lei_lamant/article/details/85605690