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

发布于 2024-12-10 01:36:21 字数 890 浏览 0 评论 0原文

我正在使用 start /AFFINITY [n] [.exe] 命令启动具有指定亲和力的可执行文件。我的系统有 8 个处理器(1、2、3、4、5、6、7、8)。我想将进程设置为使用所有奇数处理器(1、3、5、7)。我不知道如何执行此操作,并且想知道是否可以使用启动命令。如果没有,是否有替代的命令行方式来做到这一点?

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

 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.

I am using the start /AFFINITY [n] [.exe] command to start an executable with the specified affinity. I have a system with 8 processors (1,2,3,4,5,6,7,8). I'd like to set the process to use all of the odd processors (1,3,5,7). I cannot figure out how to do this and would like to know if it's possible using the start command. If not, is there an alternate command-line way of doing it?

The help for the start command wasn't particularly useful:

 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

不交电费瞎发啥光 2024-12-17 01:36:21

AFFINITY 使用十六进制掩码,它应该允许对您的所有处理器。请注意,最右边的位指定最低阶 CPU (0)(请参阅知识库 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)

AFFINITY works with a hexidecimal mask that should allow granular control of all of your processors. Note that the rightmost bit specifies the lowest-order CPU (0) (see KB 299641).

For the case in question, 0xAA (10101010) requests that your process run using processors 1, 3, 5 and 7, but not 0, 2, 4 or 6. Be sure to leave out the '0x' on the command line.

 start /affinity AA app.exe

Other examples:

 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)
朱染 2024-12-17 01:36:21

要获得正确的十六进制编号,请想象您的内核采用平面格式 8765 4321(适用于 8 核 CPU)向后方向(但不像 1234 5678)

要激活内核 7、6 和 3,请输入数字 0x64亲和力:

/AFFINITY 0x64

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

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

另请参阅:启动在 Windows 7、8 或 Vista 中分配给特定 CPU 的应用程序

To get right HEX number imagine your cores in plane format 8765 4321 (for 8-core CPU) in backward direction (but NOT like 1234 5678)

To get cores 7, 6 and 3 activated, type number 0x64 for affinity:

/AFFINITY 0x64

For better look, match and compare: 0110 0100 - number = 0x64 (8765 4321) - cores

For @ladenedge example: /AFFINITY AA 1010 1010 - number = 0xAA (8765 4321) - cores

See also: Start an Application Assigned to a Specific CPU in Windows 7, 8, or Vista

感情洁癖 2024-12-17 01:36:21

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

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”掩码

参考:搜索“这些是” 8-CPU 系统模式的关联掩码值位于 https://msdn.microsoft .com/en-US/library/ms187104.aspx

More info for your own computation needs:

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)

Consequently:

  • Mask for CPU IDs 0, 1, 2, 3, 4, 5, 6, 7: 255 (sum of individual CPU decimal values), that is the 'FF' mask as hexadecimal
  • Mask for CPU IDs 0, 2, 4, 6 : 85 (sum of individual CPU decimal values), that is the '55' mask as hexadecimal

Reference: search the 'These are affinity mask values for an 8-CPU system' pattern at https://msdn.microsoft.com/en-US/library/ms187104.aspx.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文