如何防止子分叉进程继承CPU亲和性?

时间:2022-11-03 17:00:27

I have a server process that forks many child processes. The server process has affinity to a CPU core, but I don't want that affinity to be inherited by child process (rather OS should handle where to run these processes). Is there a way to delink parent child processes with respect to cpu affinity?

我有一个服务器进程,它会分叉许多子进程。服务器进程与CPU核心具有亲缘关系,但我不希望子进程继承该亲和性(而OS应该处理运行这些进程的位置)。有没有办法在cpu亲和力方面脱钩父子进程?

1 个解决方案

#1


7  

You can call sched_setaffinity(2) with all bits set in CPU mask after the fork(2) and before the execve(2).

您可以在fork(2)之后和execve(2)之前使用CPU掩码中设置的所有位调用sched_setaffinity(2)。

#1


7  

You can call sched_setaffinity(2) with all bits set in CPU mask after the fork(2) and before the execve(2).

您可以在fork(2)之后和execve(2)之前使用CPU掩码中设置的所有位调用sched_setaffinity(2)。