如何防止子进程继承CPU亲和力?
我有一个服务器进程,它派生许多子进程。服务器进程与 CPU 核心具有亲和力,但我不希望子进程继承该亲和力(而是操作系统应该处理在何处运行这些进程)。有没有办法在 cpu 亲和力方面取消父子进程的链接?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以调用
sched_setaffinity(2)
在fork(2)
和execve(2)
。You can call
sched_setaffinity(2)
with all bits set in CPU mask after thefork(2)
and before theexecve(2)
.