设为首页 收藏本站
查看: 639|回复: 0

[经验分享] [Windows编程] Windows 7 对多核的支持

[复制链接]
发表于 2018-6-14 09:35:19 | 显示全部楼层 |阅读模式
Windows 7 和 Windows Server 2008 R2 一个重要更新是增强了对多核的支持。 现已可以支持超过64个逻辑处理器(也就是所谓的“核”),并且引入了NUMA 技术, 大幅度提高多核运算的性能。
传统的多核运算是使用SMP(Symmetric Multi-Processor )模式:将多个处理器与一个集中的存储器和I/O总线相连。所有处理器只能访问同一个物理存储器,因此SMP系统有时也被称为一致存储器访问(UMA)结构体系,一致性意指无论在什么时候,处理器只能为内存的每个数据保持或共享唯一一个数值。很显然,SMP的缺点是可伸缩性有限,因为在存储器和I/O接口达到饱和的时候,增加处理器并不能获得更高的性能。
NUMA模式是一种分布式存储器访问方式,处理器可以同时访问不同的存储器地址,大幅度提高并行性。 NUMA模式下,处理器被划分成多个"节点"(node), 每个节点被分配有的本地存储器空间。 所有节点中的处理器都可以访问全部的系统物理存储器,但是访问本节点内的存储器所需要的时间,比访问某些远程节点内的存储器所花的时间要少得多。
在开发Windows7 上的多线程程序的时候, 应该把进程内所有的线程都安排到同一个节点,可以大大提高性能。 新的Windows 7 API 函数 SetProcessAffinityMask  可以实现这个功能。
如果你的程序使用内存比较频繁, 应该在进程所在节点的本地存储器空间分配内存,以避免跨节点存储器访问的开销。 Windows API VirtualAllocExNuma  可以实现这个功能。
以下是Windows 7/ WIndows Server2 2008R2 新增加的多核支持API函数:
CreateRemoteThreadEx
Creates a thread that runs in the virtual address space of another process and optionally specifies extended attributes such as processor group affinity.
GetActiveProcessorCount
Returns the number of active processors in a processor group or in the system.
GetActiveProcessorGroupCount
Returns the number of active processor groups in the system.
GetCurrentProcessorNumberEx
Retrieves the processor group and number of the logical processor in which the calling thread is running.
GetLogicalProcessorInformationEx
Retrieves information about the relationships of logical processors and related hardware.
GetMaximumProcessorCount
Returns the maximum number of logical processors that a processor group or the system can support.
GetMaximumProcessorGroupCount
Returns the maximum number of processor groups that the system supports.
GetNumaAvailableMemoryNodeEx
Retrieves the amount of memory that is available in the specified node as a USHORT value.
GetNumaNodeNumberFromHandle
Retrieves the NUMA node associated with the underlying device for a file handle.
GetNumaNodeProcessorMaskEx
Retrieves the processor mask for the specified NUMA node as a USHORT value.
GetNumaProcessorNodeEx
Retrieves the node number of the specified logical processor as a USHORT value.
GetNumaProximityNodeEx
Retrieves the node number as a USHORT value for the specified proximity identifier.
GetProcessGroupAffinity
Retrieves the processor group affinity of the specified process.
GetProcessorSystemCycleTime
Retrieves the cycle time each processor in the specified group spent executing deferred procedure calls (DPCs) and interrupt service routines (ISRs).
GetThreadGroupAffinity
Retrieves the processor group affinity of the specified thread.
GetThreadIdealProcessorEx
Retrieves the processor number of the ideal processor for the specified thread.
QueryIdleProcessorCycleTimeEx
Retrieves the accumulated cycle time for the idle thread on each logical processor in the specified processor group.
SetThreadGroupAffinity
Sets the processor group affinity for the specified thread.
SetThreadIdealProcessorEx
Sets the ideal processor for the specified thread and optionally retrieves the previous ideal processor.
以下是新的线程池 API 函数

QueryThreadpoolStackInformation
Retrieves the stack reserve and commit sizes for threads in the specified thread pool.
SetThreadpoolCallbackPersistent
Specifies that the callback should run on a persistent thread.
SetThreadpoolCallbackPriority
Specifies the priority of a callback function relative to other work items in the same thread pool.
SetThreadpoolStackInformation
Sets the stack reserve and commit sizes for new threads in the specified thread pool.

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-523582-1-1.html 上篇帖子: Powershell 查询 Windows 日志 下篇帖子: Windows Server 2016 简介和安装
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表