当前位置: 首页 > news >正文

[Windows编程] Windows 7 对多核的支持

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.

>> 原创文章的版权属于作者,转载请注明出处和作者信息(http://blog.csdn.net/WinGeek/), 谢谢。 <<

相关文章:

  • LeetCode -- Palindrome Linked List
  • SSH客户端设置环境变量
  • LeetCode -- Search for a Range
  • 老子生平
  • LeetCode -- Simplify Path
  • 老子著述
  • LeetCode -- Single Number
  • LeetCode -- Find Peak Element
  • 老子思想
  • LeetCode -- Add Two Numbers
  • LeetCode – Combination Sum
  • ArcGIS Server Java ADF 案例教程 21
  • LeetCode -- Contains Duplicate
  • HelloCpp上线服务
  • LeetCode -- Happy Number
  • __proto__ 和 prototype的关系
  • 【笔记】你不知道的JS读书笔记——Promise
  • 【腾讯Bugly干货分享】从0到1打造直播 App
  • angular组件开发
  • JAVA 学习IO流
  • Java|序列化异常StreamCorruptedException的解决方法
  • JavaScript-Array类型
  • leetcode386. Lexicographical Numbers
  • oschina
  • passportjs 源码分析
  • react-native 安卓真机环境搭建
  • vue从创建到完整的饿了么(18)购物车详细信息的展示与删除
  • 从0实现一个tiny react(三)生命周期
  • 多线程 start 和 run 方法到底有什么区别?
  • 每个JavaScript开发人员应阅读的书【1】 - JavaScript: The Good Parts
  • 前端工程化(Gulp、Webpack)-webpack
  • 突破自己的技术思维
  • 项目实战-Api的解决方案
  • 小程序button引导用户授权
  • elasticsearch-head插件安装
  • 关于Android全面屏虚拟导航栏的适配总结
  • 国内唯一,阿里云入选全球区块链云服务报告,领先AWS、Google ...
  • 好程序员大数据教程Hadoop全分布安装(非HA)
  • ​一、什么是射频识别?二、射频识别系统组成及工作原理三、射频识别系统分类四、RFID与物联网​
  • ​中南建设2022年半年报“韧”字当头,经营性现金流持续为正​
  • # C++之functional库用法整理
  • #基础#使用Jupyter进行Notebook的转换 .ipynb文件导出为.md文件
  • #经典论文 异质山坡的物理模型 2 有效导水率
  • (007)XHTML文档之标题——h1~h6
  • (Java数据结构)ArrayList
  • (react踩过的坑)antd 如何同时获取一个select 的value和 label值
  • (十五)使用Nexus创建Maven私服
  • (转载)在C#用WM_COPYDATA消息来实现两个进程之间传递数据
  • ******IT公司面试题汇总+优秀技术博客汇总
  • ../depcomp: line 571: exec: g++: not found
  • .NET 药厂业务系统 CPU爆高分析
  • .NET/C# 检测电脑上安装的 .NET Framework 的版本
  • .NET/C# 使用 ConditionalWeakTable 附加字段(CLR 版本的附加属性,也可用用来当作弱引用字典 WeakDictionary)
  • .NET/C# 中设置当发生某个特定异常时进入断点(不借助 Visual Studio 的纯代码实现)
  • .NET设计模式(8):适配器模式(Adapter Pattern)