网站首页  词典首页

请输入您要查询的函数:

 

术语 setthreadaffinitymask
释义 SetThreadAffinityMask
语法:
C++
DWORD_PTR WINAPI SetThreadAffinityMask(
__in HANDLE hThread,
__in DWORD_PTR dwThreadAffinityMask
);
SetThreadAffinityMask功能
设置一个指定的线程处理器关联掩码。
参数
hThread [in]
一个句柄,线程的关联掩码被设置。
这种处理必须有THREAD_SET_INFORMATION或THREAD_SET_LIMITED_INFORMATION访问权和THREAD_QUERY_INFORMATION或THREAD_QUERY_LIMITED_INFORMATION访问权限。有关更多信息,请参见线程安全和访问权限。
Windows Server 2003和Windows XP/2000操作系统:句柄必须具有THREAD_SET_INFORMATION和THREAD_QUERY_INFORMATION访问权限。
dwThreadAffinityMask [in]
线程的关联掩码。
在一个拥有6400多处理器,相似性掩码必须指定线程的当前处理器小组处理器系统。
返回值
如果函数成功,返回值是线程的前相似性掩码。
如果函数失败,返回值是零。为了获得更多错误信息,调用GetLastError。
如果线程关联掩码请求不是为这一进程关联掩码选择处理器,最后一个错误代码是ERROR_INVALID_PARAMETER。
备注
线程关联掩码是位向量中的每一位代表一个逻辑处理器,线程允许运行。线程关联掩码必须是为线程的含有的过程相似性掩码的子集。只能一个线程处理器上运行的进程可以运行。因此,线程关联掩码不能指定处理器时,进程关联掩码指定该位处理器0 1 1位。
设置一个进程或线程关联掩码可以导致接收线程处理器时间少,因为系统是由某些处理器上运行的线程限制。在大多数情况下,最好是让系统选择可用的处理器。
如果新的线程关联掩码不指定处理器是当前正在运行的线程,线程就重新安排允许的处理器之一。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinbase.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
参见
GetProcessAffinityMask
多处理器
OpenThread
进程和线程函数
处理器组
SetProcessAffinityMask
SetThreadIdealProcessor
主题
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月27日
==英文原文==SetThreadAffinityMask Function
Sets a processor affinity mask for the specified thread.
Syntax
C++
DWORD_PTR WINAPI SetThreadAffinityMask(
__in HANDLE hThread,
__in DWORD_PTR dwThreadAffinityMask
);
Parameters
hThread [in]
A handle to the thread whose affinity mask is to be set.
This handle must have the THREAD_SET_INFORMATION or THREAD_SET_LIMITED_INFORMATION access right and the THREAD_QUERY_INFORMATION or THREAD_QUERY_LIMITED_INFORMATION access right. For more information, see Thread Security and Access Rights .
Windows Server 2003 and Windows XP/2000: The handle must have the THREAD_SET_INFORMATION and THREAD_QUERY_INFORMATION access rights.
dwThreadAffinityMask [in]
The affinity mask for the thread.
On a system with more than 64 processors, the affinity mask must specify processors in the thread's current processor group .
Return Value
If the function succeeds, the return value is the thread's previous affinity mask.
If the function fails, the return value is zero. To get extended error information, call GetLastError .
If the thread affinity mask requests a processor that is not selected for the process affinity mask, the last error code is ERROR_INVALID_PARAMETER.
Remarks
A thread affinity mask is a bit vector in which each bit represents a logical processor that a thread is allowed to run on. A thread affinity mask must be a subset of the process affinity mask for the containing process of a thread. A thread can only run on the processors its process can run on. Therefore, the thread affinity mask cannot specify a 1 bit for a processor when the process affinity mask specifies a 0 bit for that processor.
Setting an affinity mask for a process or thread can result in threads receiving less processor time, as the system is restricted from running the threads on certain processors. In most cases, it is better to let the system select an available processor.
If the new thread affinity mask does not specify the processor that is currently running the thread, the thread is rescheduled on one of the allowable processors.
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinbase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll
See Also
GetProcessAffinityMask
Multiple Processors
OpenThread
Process and Thread Functions
Processor Groups
SetProcessAffinityMask
SetThreadIdealProcessor
Threads
Send comments about this topic to Microsoft
Build date: 8/27/2009
==原始网址==http://msdn.microsoft.com/en-us/library/ms686247(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 13:22:01