setting cpu affinity of a process from the start on linux

后端 未结 1 1165
滥情空心
滥情空心 2021-01-11 10:04

I want to set the cpu affinity of a process on linux when it is starting.

There are methods like sched_setaffinity and taskset, but they need the processid of the pr

相关标签:
1条回答
  • 2021-01-11 10:19

    taskset can be used both to set the affinity of a running process or to launch a process with a certain affinity, see

    • How to launch your application in a specific CPU in Linux (CPU affinity)?.
    • man page for taskset

    Synopsis

    taskset [options] mask command [arg]...
    taskset [options] -p [mask] pid
    

    The below command will launch Google Chrome browser in CPU 1 & 2 (or 0 and 1). The mask is 0×00000003 and command is “google-chrome”.

    taskset 0×00000003 google-chrome
    
    0 讨论(0)
提交回复
热议问题