如何防止子进程继承CPU亲和力?

发布于 2024-12-19 02:22:47 字数 107 浏览 2 评论 0原文

我有一个服务器进程,它派生许多子进程。服务器进程与 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

猫瑾少女 2024-12-26 02:22:47

您可以调用 sched_setaffinity(2)fork(2)execve(2)

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文