在Windows 7上使用start / AFFINITY命令设置关联

时间:2011-10-13 20:17:54

标签: windows-7 command-line affinity

我正在使用start /AFFINITY [n] [.exe]命令启动具有指定关联的可执行文件。我有一个带8个处理器的系统(1,2,3,4,5,6,7,8)。我想设置进程使用所有奇数处理器(1,3,5,7)。我无法弄清楚如何做到这一点,并想知道是否可以使用start命令。如果没有,是否有其他命令行方式呢?

启动命令的帮助不是特别有用:

 AFFINITY    Specifies the processor affinity mask as a hexadecimal number.
             The process is restricted to running on these processors.

             The affinity mask is interpreted differently when /AFFINITY and
             /NODE are combined.  Specify the affinity mask as if the NUMA
             node's processor mask is right shifted to begin at bit zero.
             The process is restricted to running on those processors in
             common between the specified affinity mask and the NUMA node.
             If no processors are in common, the process is restricted to
             running on the specified NUMA node.

3 个答案:

答案 0 :(得分:22)

AFFINITY与hexidecimal mask配合使用,可以对所有处理器进行精细控制。请注意,最右边的位指定最低级别的CPU(0)(请参阅KB 299641)。

对于有问题的情况,0xAA(10101010)请求您的进程使用处理器1,3,5和7运行,但不是0,2,4或6.确保在命令中省略'0x'线。

 start /affinity AA app.exe

其他例子:

 start /affinity 1 app.exe     (only use CPU 0)
 start /affinity 2 app.exe     (only use CPU 1)
 start /affinity 1F app.exe    (only use CPUs 0, 1, 2, 3, and 4)

答案 1 :(得分:9)

要获得正确的十六进制数,请想象你的核心是平面格式8765 4321(对于8核CPU)向后(但不像1234 5678)

要激活核心7,6和3,请为亲缘关系键入数字0x64

/AFFINITY 0x64

为了更好地查看,匹配和比较:0110 0100 - 数字= 0x64(8765 4321) - 核心

对于@ladenedge示例:/AFFINITY AA 1010 1010 - 数字= 0xAA(8765 4321) - 核心

另请参阅:Start an Application Assigned to a Specific CPU in Windows 7, 8, or Vista

答案 2 :(得分:4)

有关您自己的计算需求的更多信息:

CPU ID  CPU value (dec)
0       001 (= 2^0)
1       002 (= 2^1)
2       004 (= 2^2)
3       008 (= 2^3)
4       016 (= 2^4)
5       032 (= 2^5)
6       064 (= 2^6)
7       128 (= 2^7)

因此:

  • CPU ID的掩码0,1,2,3,4,5,6,7:255(各个CPU十进制值的总和),即'FF'掩码为十六进制
  • CPU ID 0,2,4,6:85(各个CPU十进制值之和)的掩码,即十六进制的“55”掩码

参考:在https://msdn.microsoft.com/en-US/library/ms187104.aspx搜索'这些是8-CPU系统的亲和力掩码值'模式。

相关问题