2

Goal: My goal is to set all running processes's affinity to 1 core. Then launch a program with the affinity of all the cores.

Skill Lvl: My skill level in programming in general is pretty much beginner. This is my first language.

Need: I would like some help with this coding and maybe an article or description of the code. Thank you

4

1 回答 1

1

这里有一个 C# 解决方案。

总之,您需要遍历所有进程 ( Process.GetProcesses) 并将它们设置.ProcessorAffinityNew IntPtr(1),然后开始您的新进程。(默认已经使用所有内核,但为了完整起见,如果您希望新进程具有不同的亲和性,请在启动后以与上述相同的方式进行设置。)

所有代码:

Dim procs = Process.GetProcesses
For Each p In procs
 p.ProcessorAffinity = New IntPtr(1)
Next
Dim myProc = Process.Start("notepad.exe")
' Stop here to answer the OP.
' This sets the new Notepad process to be the only process running on the second CPU:
myProc.ProcessorAffinity = New IntPtr(2)
于 2012-11-06T06:53:54.927 回答