Limit the current thread to one processor
来源:互联网 发布:dota淘宝交易 编辑:程序博客网 时间:2024/05/18 14:45
//--------------------------------------------------------------------------------------
// Limit the current thread to one processor (the current one). This ensures that timing code
// runs on only one processor, and will not suffer any ill effects from power management.
// See "Game Timing and Multicore Processors" for more details
//--------------------------------------------------------------------------------------
void LimitThreadAffinityToCurrentProc()
{
HANDLE hCurrentProcess = GetCurrentProcess();
// Get the processor affinity mask for this process
DWORD_PTR dwProcessAffinityMask = 0;
DWORD_PTR dwSystemAffinityMask = 0;
if( GetProcessAffinityMask( hCurrentProcess, &dwProcessAffinityMask, &dwSystemAffinityMask ) != 0 &&
dwProcessAffinityMask )
{
// Find the lowest processor that our process is allows to run against
DWORD_PTR dwAffinityMask = ( dwProcessAffinityMask & ( ( ~dwProcessAffinityMask ) + 1 ) );
// Set this as the processor that our thread must always run against
// This must be a subset of the process affinity mask
HANDLE hCurrentThread = GetCurrentThread();
if( INVALID_HANDLE_VALUE != hCurrentThread )
{
SetThreadAffinityMask( hCurrentThread, dwAffinityMask );
CloseHandle( hCurrentThread );
}
}
CloseHandle( hCurrentProcess );
}
- Limit the current thread to one processor
- the limit to the amount of thread from a process
- thread processor
- Sort the array one by one without changing current array
- Java - Get the information of the current thread
- Ubuntu wine / winetricks解决this msxml 6.0 is not supported on the current processor type
- JPA -the annotation about one to one
- Annotation Processor - How to get the Class it is processing
- Step By Step To Start The Output Post Processor
- How to get the current epoch time
- How to limit an array of similar hashes to those that have more than one of the same key:value pair
- JavaCC How to limit one-time occurrence clause
- How to get current thread ID in asp.net
- Scope 'session' is not active for the current thread
- Scope 'request' is not active for the current thread
- maven: Unable to add module to the current project
- Unable to update database to match the current model!
- One-by-one to solve the Sequence Problem (1)
- ORACLE实例的后台进程
- 【转】Oracle服务器的常用命令行详细讲解
- 深入剖析iLBC的丢包补偿技术(PLC)
- 老虎的屁股摸不得,宝宝的屁屁一样碰不得!
- Smart Device Framework ( SDF )类库
- Limit the current thread to one processor
- 初识加密算法
- 关于javascript控制Windows Media Player
- inux下安装新硬盘并加载使用手记
- 很多日本鬼子
- Linux netfilter源码分析(1)
- ASP.NET - ConnectionsZone Web 服务器控件概述
- [HL7_V2.6]查询医嘱XML
- UE,EP添加右键