I want to be able to use multiple cores in my XNA game, but it seems that Thread.SetProcessorAffinity() is only usable on xbox. That being said, is there any way to run a small chunk of my code on another core, or failing that, share the load between all cores?
|
|
That being said I'm confused by the second part of your question. Windows threads by default are set to run on all processors/cores. The thread affinity mask exists to allow you to specify that it can only run on specific cores. This is useful in some rare cases where system calls return differently depending on the core/processor that the thread is currently running on such as QueryPerformanceCounter Edit: After researching XNA's Thread.SetProcesorAfffinity I think you might just be misunderstanding how multiprocessing works in Windows. Most windows applications do not call SetThreadAffinityMask but instead just create threads and let the OS choose what core/processor (remember some machines have more than one processor) to run the thread on. Windows has a complex scheduler that suspends and resumes threads based off of thread priority to allow more threads than there are physical processors or cores. If you want to learn more I recommend reading one of the Windows Internal books or one of the powerpoints floating around on the web that explain Win32 Kernel. |
||||
|