问题标签 [setthreadaffinitymask]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
151 浏览

c++ - 在 android 上为 sched_setaffinity 唤醒睡眠 CPU

我在运行多个线程的应用程序上工作,一个线程是最重要的,并且必须在最强的 cpu 上运行。我使用 c++ 函数 sched_setaffinity 成功地将这个线程附加到选择的 cpu。

syscallres = syscall(__NR_sched_setaffinity, pid, sizeof(cpu_set), &cpu_set);

在我的 android 设备上,第一个 cpu 最强,其他 3 个较弱,最后 4 个是省电的。首先是最强的并且始终处于开启状态,但是根据文档,cpu 可能会休眠并且必须在我将线程附加到 cpu 之前唤醒,并且实际上,根据 stackoverflow 上的帖子,人们在睡觉时无法将线程固定到 cpu。我无法在我的设备上模拟它,我总是成功地将线程附加到选择的 cpu,也许它取决于操作系统。所以我的问题是,在我调用“sched_setaffinity”之前启动 cpu 的正确方法是什么?

0 投票
1 回答
250 浏览

affinity - 检查 PF_NO_SETAFFINITY 的值

是否可以判断进程/线程是否PF_NO_SETAFFINITY设置了标志?我在一系列进程 ID 上运行任务集,其中一些正在抛出以下形式的错误:

taskset: failed to set pid 30's affinity: Invalid argument

我相信这是因为已经PF_NO_SETAFFINITY设置了一些流程(请参阅答案)。

谢谢!