如果我们使用任务集通过进程 pid 设置特定进程在特定核心上运行。我想知道由 pid 生成的所有子进程也将在特定核心上运行或使用任何核心。
最佳答案
taskset
调用 sched_setaffinity(2)
( here ) 来指定线程有资格运行的 CPU 集。正如 sched_setaffinity(2)
的 manual状态:
A child created via
fork(2)
inherits its parent's CPU affinity mask. The affinity mask is preserved across anexecve(2)
.
允许子进程与其父进程在同一组 CPU 上运行。
关于cpu - Linux 中的任务集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42762730/