123456

 

SetThreadAffinityMask 把线程限定在CPU上运行

很简单的函数:

比如把当前线程限制在CPU0(第一个processor)上运行:

SetThreadAffinityMask(GetCurrentThread(), 1)

第0位是1

又比如要把当前线程限制在CPU1,CPU2这两个上运行:

SetThreadAffinityMask(GetCurrentThread(), 6)

第1,2位同时为1
 

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, callGetLastError.

以前没用过,突然发现,小记下

posted on 2012-10-07 09:14  hgy413  阅读(653)  评论(0编辑  收藏  举报

导航