force scheduler to allocate thread to specific processor

白昼怎懂夜的黑 提交于 2019-12-04 15:23:27

If you look at the man page for taskset you can see the following statement:

The Linux scheduler will honor the given CPU affinity and the process will not run on any other CPUs.

This means that setting the CPU affinity for a particular process will make sure that it's always run on that CPU.

There exist API's that allow you to set thread affinity for particular threads, and I would imagine that this too will be honored by the OS scheduler.

If you look at sched_setaffinity you'll see a line that says:

These restrictions on the actual set of CPUs on which the process will run are silently imposed by the kernel.

which means this will make sure your threads are only run on CPU's set by this function.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!