Processor affinity in windows?

Hi,

I am going to deploy my game on a PC with dual core. I need one of the cores to be 100% committed to a certain background thread that I open in my game, and for the rest of the game (or at least most of it) to run on the other core.

Is there any way I can control this in unity?

There is a way for you to tell the OS which core you want a certain thread to run on. Take a look at these two links:

The first one sets an indication for the scheduler to heed, while the other one directly sets a process’ CPU affinity. This means you can dictate that your background thread must run on a particular core, but your application is still at the mercy of the OS scheduler; you can’t reserve an entire CPU core for one thread. But I suppose you can make the core whose number you set an affinity for so busy that the OS scheduler consistently chooses another one for other tasks. :wink:

Has anyone actually gotten Unity to accept a non-core0 processor affinity in Windows stand-alone from within Unity code?

Setting processor affinity fails in 3.4+, which limits the number of -batchmode host instances one can run on a server. (Unless you hack together another process to manage them)

Anyone dealt with this?,We are trying to set Affinity to unique cores for multiple -batchmode instances, but Unity seems to overwrite affinity back to core0.

I’ve seen several threads on the topic, but has anyone successfully set affinity within their Unity code using 3.4+?