How to force two process to run on the same CPU?

两盒软妹~` 提交于 2019-12-04 11:17:42

I think you may be able to start with these manual pages:

$ apropos affinity
sched_getaffinity (2) - set and get a process's CPU affinity mask
sched_setaffinity (2) - set and get a process's CPU affinity mask
taskset (1)          - retrieve or set a process's CPU affinity
$

depending on whether you want to do that from the source code or the shell. The pthread library also has some function.

In C what you are looking for is most probably the sched_setaffinity() system call.

There is also the schedtool command-line utility if you do not want to (or cannot) modify your code.

Writing NUMA aware apps is a little bit more than just 'two processes run on same CPU'. NUMA awareness permeates everything: memory allocation, IO completion, thread scheduling etc.

Have a look at libnuma

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