1

I'm doing a PC based automation programs in C# and I have some problem when Windows start using some of the CPU I have assign to my program. I know i can specify which core can execute a process by looping the running processes in C# and changing their affinity but I'm looking for a way to do it automatically. Is there any way to force a program to use, by example, only the 2 first core by default, so if an application start after mine it will not start using " my " core ?

Thank you!

Anubian Noob
  • 13,426
  • 6
  • 53
  • 75
pascx64
  • 904
  • 16
  • 31
  • 2
    Not in any reasonable or practical way. You can set core affinity for an executable using some command-line tool, but it doesn't really help you much. In any case, you're looking at this wrong anyway - Windows is *not* an real-time OS. It does not give you many execution latency guarantees, and it's usually a bad idea to interfere with how it distributes work. What problem are you trying to solve? – Luaan Jun 27 '14 at 14:55
  • http://msdn.microsoft.com/en-us/library/jj200349.aspx – Hans Passant Jun 27 '14 at 15:04
  • possible duplicate of [How to set processor affinity on an executable in Windows XP?](http://stackoverflow.com/questions/628057/how-to-set-processor-affinity-on-an-executable-in-windows-xp) – josh poley Jun 27 '14 at 15:29
  • @Luaan Everything work correctly 99% of the time. But sometime some other windows process will start doing some work and I'm getting miss frame. I've already distribute my threads affinity. Problems happen when other process start working on the core I'm using. I'm using 90% of the 10 of my 12 core so I was looking for a way to force other processes to work on the 2 first core – pascx64 Jun 27 '14 at 15:38
  • @joshpoley This isn't the answer I am looking for. I want to automatically changer the affinity of starting process, or in other words, the default affinity – pascx64 Jun 27 '14 at 17:47
  • @pascx64 Looking at the answers in that thread you can see that there isn't a way to set that for all processes. And even if there was a way, you still have no mechanism to prevent processes from changing their own affinity. – josh poley Jun 27 '14 at 17:55
  • Have you considered using a virtual machine to separate the processes? You could run your own 10-core thingy inside a virtual OS, and get rid of all the features you don't need. – Luaan Jun 30 '14 at 07:30

1 Answers1

0

after some research I finaly decided to use a real time extension to windows. I'm currently trying Kithara. This looks promising. Unfortunately, I must transfer some code in C++.

Thank for your help!

pascx64
  • 904
  • 16
  • 31