【问题标题】:Do the changes to cpumask using sched_setaffinity() take place immediately立即使用 sched_setaffinity() 对 cpumask 进行更改
【发布时间】:2010-04-01 10:01:19
【问题描述】:

我正在编写一个 linux 内核模块,它需要将两个线程固定在两个不同的 cpu 上。我计划在将 sched_setaffinity() 导出到内核后使用它。是否还有其他相同的导出功能?

另外,如果我在 cpumask 中只设置了 1 个 CPU,线程会立即移动到该 cpu 吗?如果没有,我该如何执行?在 sched_setaffinity() 之后调用 schedule() 会有所帮助吗?

【问题讨论】:

标签: multithreading linux-kernel affinity


【解决方案1】:

sched_setaffinity 的手册页说

如果pid 指定的进程当前未在mask 指定的CPU 之一上运行,则该进程将迁移到mask 指定的CPU 之一。

我的解释是,这种迁移会在对 sched_setaffinity 的调用返回之前立即发生。

【讨论】:

    猜你喜欢
    • 2011-11-21
    • 1970-01-01
    • 2020-11-16
    • 2021-10-29
    • 1970-01-01
    • 2017-04-17
    • 2020-07-09
    • 2021-12-12
    • 1970-01-01
    相关资源
    最近更新 更多