如今,设置线程关联而不是将其留给操作系统的充分理由是什么? [英] These days, what are good reasons for setting thread affinity rather than leaving it to the OS?

查看:66
本文介绍了如今,设置线程关联而不是将其留给操作系统的充分理由是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在此处搜索线程亲缘关系"的答案,我发现对此很感兴趣,但对其进行的论证很少,可能会获得稳定的QueryPerformanceTimer结果.

Searching answers here for "thread affinity", I see a lot of interest in doing it but little justification for it save possibly getting stable QueryPerformanceTimer results.

假设一个现代操作系统和一个具有现代4-6核心CPU的现代2-4插槽工作站/服务器类计算机,那么有什么充分的理由会让人认为他们比操作系统的调度程序更了解呢?在现实世界中,是否有做正确的事来更好地控制广告亲和力的情况?可以证明什么样的性能优势?

Assuming a modern OS and a modern 2-4 socket workstation/server class machine with modern 4-6 core CPUs, what good reasons would anyone have for thinking they know better than their OS's scheduler ? Are there any real world situations where taking more control of thead affinity is the right thing to do ? What sort of performance benefits can be demonstrated ?

上次我看到在某个地方设置线程亲和力的一个很好的案例(例如,它得到了显示系统性能真正和显着改善的具体结果的支持),这与Win2K设备驱动程序有些晦涩.但是多年来,我还没有看到过类似的东西,所以这些天当有人告诉我他们需要控制线程的亲和力(但不是为什么)时,我深感怀疑……但很想知道否则的话.

The last time I saw a really good case for setting thread affinity somewhere (as in, it was backed up by concrete results showing genuine and significant improvements in system performance), it was some obscure thing to do with Win2K device drivers. But I haven't seen anything like that in years so when someone tells me they need to control thread affinity (but not why) these days I am deeply sceptical... but curious to be shown otherwise.

推荐答案

在OS内核中,有时在内核模式驱动程序中,您需要在每个CPU上执行相同的操作(例如,更新系统寄存器).您可以在单个线程中循环执行此操作,更改每次迭代的亲和力.

In the OS kernel and sometimes in kernel mode drivers you need to perform the same action on every CPU (e.g. update a system register). You can do that in a loop in a single thread, changing the affinity on each iteration.

这篇关于如今,设置线程关联而不是将其留给操作系统的充分理由是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆