简体   繁体   English

调度程序是否可以通过`sched_setaffinity`自动将亲和性已设置为非常繁忙的cpu的线程迁移到空闲cpu?

[英]Could scheduler automatically migrate the thread whose affinity has been set to a very busy cpu through `sched_setaffinity` to a free cpu?

Could scheduler automatically migrate the thread whose affinity has been set to a very busy cpu through sched_setaffinity to a free cpu?调度器是否可以通过sched_setaffinity自动将亲和度设置为非常繁忙的 cpu 的线程迁移到空闲的 cpu 上?

Does sched_setaffinity implement a "hard affinity" or a "soft affinity"? sched_setaffinity是实现“硬关联”还是“软关联”?

What i called "soft affinity" is that it tells scheduler the thread prefers to run on a particular cpu and could be migrated to other cpu if necessary.我所说的“软亲和力”是它告诉调度程序线程更喜欢在特定的 cpu 上运行,并且可以在必要时迁移到其他 cpu。

What i called "hard affinity" is that it tells scheduler the thread must run on particular cpu no matter how long the thread has to wait for the cpu resources.我所说的“硬关联”是它告诉调度程序线程必须在特定的 cpu 上运行,无论线程必须等待 cpu 资源多长时间。

I clearly remember that there are apis which could provide "soft affinity" and "hard affinity" under windows indeed.Is there any api could provide "soft affinity" under linux?我清楚地记得确实有可以在windows下提供“软亲和力”和“硬亲和力”的api。api可以在linux下提供“软亲和力”吗?

No. If a process has affinity to one CPU only, it will only run on that CPU no matter what.不会。如果一个进程只与一个 CPU 有关联,那么无论如何它都只会在该 CPU 上运行。 In other words, this fits your definition of "hard affinity".换句话说,这符合您对“硬亲和力”的定义。

This feature can of course be a double edged sword if used incorrectly: setting the affinity of a task to a single CPU gives great benefit if the CPU is dedicated to that task only, but degrades performance if the CPU is not and it somehow gets under heavy load.如果使用不当,此功能当然可能是一把双刃剑:如果 CPU 仅专用于该任务,则将任务的亲和性设置为单个 CPU 会带来很大好处,但如果 CPU 不是专用于该任务,则会降低性能并且它会以某种方式受到影响重物。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM