如何在 Windows XP 中的可执行文件上设置处理器关联?

发布于 2024-07-14 23:04:48 字数 541 浏览 15 评论 0原文

我有一个带有第三方应用程序的四核系统,偶尔会旋转多个进程(始终是相同的可执行文件,但有多个实例)并占用 100% 的 CPU 时间。 我还在同一个机器上运行了几个 Web 服务(IIS 和第三方)。

所有核心都繁忙的问题是,它会使第三方 Web 服务器超时(尽管 IIS 工作正常,只是比平常慢)。 我无法控制第三方网络服务器,它是更大产品的一部分,必须能够运行。 因此,我尝试使用处理器亲和力(通过 SysInternals Process Explorer)并将这些讨厌的进程限制为 4 个核心中的 3 个,并将第 4 个核心专用于第三方 Web 服务器,它似乎工作得很好。

问题是它只在正在运行的进程上设置亲和力,而不是在可执行文件级别上设置亲和力,因此在这些进程完成并稍后作为新进程重生后,一切又都是一样的 - 它们占用全部 4 个核心。 因此,我在 google 上搜索了 Microsoft 的 ImageCfg.exe 实用程序,但我在 Microsoft 网站上找不到它可供下载,而且我看到有些人尝试过它,但现在抱怨它实际上不起作用。

有没有办法将亲和力与可执行文件保持一致?

I have a quad core system with third party application that once in a while spins several processes (always the same executable but several instances of it) and takes 100% of CPU time. I also have a couple of web services running on the same box (IIS and third party).

The problem with the all cores being busy is that it makes this third party web server to timeout (IIS works fine though, just slower than usual). I have no control over third party web server, it's a part of the bigger product and has to be operational. So, I tried to play with processor affinity (via SysInternals Process Explorer) and limit those pesky processes to 3 cores out of 4 and dedicate the 4th core to the third party web server, and it seems to work quite well.

The problem is that it only sets affinity on the running process and not on executable level, so after those processes finish and later respawn as a new processes it's all the same again - they take all 4 cores. So, I've googled about this ImageCfg.exe utility from Microsoft but I can't find it on Microsoft webside for download and I see that some people tried it and now complain that it doesn't really work.

Is there a way to stick the affinity to the executable?

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

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

发布评论

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

评论(8

溺孤伤于心 2024-07-21 23:04:48

http://waynes-world- it.blogspot.com/2009/06/processor-affinity-on-windows-server.html

PowerShell

使用 PowerShell 为一个或多个正在运行的进程设置处理器关联性。 下面有一个示例脚本,将 calc.exe 的处理器掩码设置为前 4 个处理器。 我喜欢这种方法,因为脚本很简单,很容易安排,可以在 x86 和 x64 上运行,支持同名的多个进程,并且至少部分是因为它强调了使用 PowerShell 进行管理是多么容易。

请注意,如果您在 calc.exe (n!) 中使用大量数字的阶乘,您将生成 100% CPU,这对于测试非常有用。 下面的掩码是 0xf = 1111 – 该掩码仅允许使用前四个处理器:

$calcSet = Get-Process -ProcessName "calc"
foreach ($calc in $calcSet) {$calc.ProcessorAffinity=0xF}

http://waynes-world-it.blogspot.com/2009/06/processor-affinity-on-windows-server.html

PowerShell

Use PowerShell to set the processor affinity for one or more running processes. There’s an example script below, setting the processor mask of calc.exe to the first 4 processors. I like this method because the script is simple, it would be easy to schedule, works on x86 and x64, supports multiple processes of the same name and at least partly because it highlights just how easy administration with PowerShell is.

Note that if you use factorial of a large number with calc.exe (n!) you’ll generate100% CPU which can be useful for testing. The mask below is 0xf = 1111 – a mask allowing use of only the first four processors:

$calcSet = Get-Process -ProcessName "calc"
foreach ($calc in $calcSet) {$calc.ProcessorAffinity=0xF}
背叛残局 2024-07-21 23:04:48

Process Lasso 的一项功能是在进程启动时设置该进程的亲和力。

One feature of Process Lasso is to set the affinity of a process whenever that process is launched.

油焖大侠 2024-07-21 23:04:48

您可能需要查看 start/AFFINITY 参数。

来自帮助:

AFFINITY    The new application will have the specified processor
            affinity mask, expressed as a hexadecimal number.

由于 Windows 上的处理器亲和力是一个位掩码,您可能需要一些实验,但我假设 1 是第一个核心,因此 7 是前三个核心, F 是所有四个。 或者 8 仅用于第四个。

然后,您可以通过调用带有适当参数的 start 来替换计划任务或快捷方式。

You may want to look at the /AFFINITY parameter to start.

From the help:

AFFINITY    The new application will have the specified processor
            affinity mask, expressed as a hexadecimal number.

As processor affinity on Windows is a bitmask you may need some experimentation but I'd assume 1 being the first core, therefore 7 being the first three cores and F being all four. Or 8 for only the fourth.

You can then replace scheduled tasks or shortcuts with a call to start with the appropriate parameters.

情仇皆在手 2024-07-21 23:04:48

ImageCfg.exe 实用程序确实有效。 我今天刚刚用它来解决公司问题。 它可以从 http://www.robpol86.com/pages/imagecfg.php

Imagecfg -a 0x3 xxx.exe将 .exe 限制为 CPU0 和 CPU1。

例如,

The ImageCfg.exe utility does work. I just used it to solve a company issue today. It is available from http://www.robpol86.com/pages/imagecfg.php

Imagecfg -a 0x3 xxx.exe

limits the .exe to CPU0 and CPU1, for example.

帅气称霸 2024-07-21 23:04:48

您可以使用单进程关联应用程序填充程序强制将一个处理器置于可执行级别,这将强制该进程进入一个核心。

本文 http://msdn.microsoft.com/en-us/library /bb173458.aspx,有一段关于启用底部垫片的内容。

You can use the single-proc affinity application shim to force one processor on the executable level, which will force the process onto one core.

This article, http://msdn.microsoft.com/en-us/library/bb173458.aspx, has a paragraph on enabling the shim towards the bottom.

ζ澈沫 2024-07-21 23:04:48

使用SetProcessAffinityMask()。 注意,处理器关联性是继承的!

请 您需要使用 ImageFileExecutionOptions,特别是“调试器”选项,并编写您的自己的小型可执行文件,它对自身调用 SetProcessAffinityMask(),然后生成一个新进程,这就是您要为其设置亲和力的进程。 将其设置为调试器,就完成了。

Use SetProcessAffinityMask(). And beware, Processor Affinity is inherited!

You'll need to use ImageFileExecutionOptions, specifically the "Debugger" option, and write your own small executable that calls SetProcessAffinityMask() on itself, and then spawns a new process, which is the one you want to set affinity for. Set that as the debugger, and you're done.

ヅ她的身影、若隐若现 2024-07-21 23:04:48

显然这个帖子已经过时了,但我还是添加了一条评论,以防万一有人用谷歌搜索这个主题(就像我所做的那样)

您可以尝试设置进程的优先级,这样即使它
决定使用 100% 的 CPU,优先级更高的东西可以
在需要时接管。

自动执行此操作(而不是必须在任务中执行
经理)是我不久前问过的问题。

start命令可用于设置进程的启动优先级。

例如。 启动“我的路径\我的进程”/LOW 以获得低优先级。

允许的优先级开关
LOW、NORMAL、HIGH、REALTIME、ABOVENORMAL、BELOWNORMAL

例如可以从批处理文件中调用。

Clearly this thread is outdated but im adding a comment anyway just in case anyone googles on this subject (as I did)

You could try setting the priority of the process so that even if it
decides to use 100% of the CPU, something that is higher priority can
take over when it needs to do so.

Doing this automatically (rather than having to play in the task
manager) is something I asked about a while ago.

The start command can be used to set startup priority of a process.

Eg. start "my path\my process" /LOW for low priority.

Allowed priority switches
LOW, NORMAL, HIGH, REALTIME, ABOVENORMAL, BELOWNORMAL

Could be called from a batchfile for example.

桜花祭 2024-07-21 23:04:48

您可以尝试设置进程的优先级,这样即使它决定使用 100% 的 CPU,更高优先级的进程也可以在需要时接管。

自动执行此操作(而不是必须在任务管理器中运行)是我询问的有关前一阵子。

You could try setting the priority of the process so that even if it decides to use 100% of the CPU, something that is higher priority can take over when it needs to do so.

Doing this automatically (rather than having to play in the task manager) is something I asked about a while ago.

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