How to control which core a process runs on?

后端 未结 9 742
挽巷
挽巷 2020-12-04 09:52

I can understand how one can write a program that uses multiple processes or threads: fork() a new process and use IPC, or create multiple threads and use those sorts of com

9条回答
  •  -上瘾入骨i
    2020-12-04 10:09

    The OS knows how to do this, you do not have to. You could run into all sorts of issues if you specified which core to run on, some of which could actually slow the process down. Let the OS figure it out, you just need to start the new thread.

    For example, if you told a process to start on core x, but core x was already under a heavy load, you would be worse off than if you had just let the OS handle it.

提交回复
热议问题