使用Windows脚本更改进程的相似性 [英] Change affinity of process with windows script

查看:102
本文介绍了使用Windows脚本更改进程的相似性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows中,

 START /node 1 /affinity ff cmd /C "app.exe"

我可以设置app.exe的相似性(app.exe使用的内核数)。

I can set the affinity of app.exe (number of cores used by app.exe).

使用Windows脚本,如何更改正在运行的进程的相似性?

With a windows script, How I can change the affinity of a running process ?

推荐答案

PowerShell可以为您完成此任务



获取关联性:



PowerShell can do this task for you

Get Affinity:

PowerShell "Get-Process app | Select-Object ProcessorAffinity"



设置相似性:



Set Affinity:

PowerShell "$Process = Get-Process app; $Process.ProcessorAffinity=255"



示例:(8核处理器)




  • 核心编号 = = BitMask

  • 核心1 = 1 = 00000001

  • 核心2 = 2 = 00000010

  • 核心3 = 4 = 00000100

  • 核心4 = 8 = 00001000

  • 核心5 = 16 = 00010000

  • 核心6 = 32 = 00100000

  • 核心7 = 64 = 01000000

  • 核心8 = 128 = 10000000

  • Example: (8 Core Processor)

    • Core # = Value = BitMask
    • Core 1 = 1 = 00000001
    • Core 2 = 2 = 00000010
    • Core 3 = 4 = 00000100
    • Core 4 = 8 = 00001000
    • Core 5 = 16 = 00010000
    • Core 6 = 32 = 00100000
    • Core 7 = 64 = 01000000
    • Core 8 = 128 = 10000000
    • 只需将十进制值加到要使用的内核上。 255 =所有8个内核。

      Just add the decimal values together for which core you want to use. 255 = All 8 cores.


      • 所有内核= 255 = 11111111

      C:\>PowerShell "Get-Process notepad++ | Select-Object ProcessorAffinity"
      
                                                                    ProcessorAffinity
                                                                    -----------------
                                                                                  255
      
      
      
      C:\>PowerShell "$Process = Get-Process notepad++; $Process.ProcessorAffinity=13"
      
      C:\>PowerShell "Get-Process notepad++ | Select-Object ProcessorAffinity"
      
                                                                    ProcessorAffinity
                                                                    -----------------
                                                                                   13
      
      
      
      C:\>PowerShell "$Process = Get-Process notepad++; $Process.ProcessorAffinity=255"
      
      C:\>
      

      来源:

      以下是有关如何更改流程亲和力的详细介绍:
      http://www.energizedtech.com/2010/07/powershell-setting-processor- a.html

      Here is a nicely detailed post on how to change a process's affinity: http://www.energizedtech.com/2010/07/powershell-setting-processor-a.html

      这篇关于使用Windows脚本更改进程的相似性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆