Archive, XNA
     

Multithreading for the Xbox 360

When multithreading on the Xbox 360, here are a few things to keep in mind.

Affinity
In multithreaded programming, programmers often lack the ability to specify the Processor Affinity of a thread. Even when API calls are available to specify a processor, it is usually ignored. The reason for this is that modern operating systems have many processes running, each with many threads. The operating system zealously manages processor affinity in order to maximum some metric.

But what about the Xbox? The Xbox 360’s operating system does not manage processor affinity. All threads run on the same processor as their parent unless otherwise stated. This basically means that you, the programmer, are responsible for managing processor affinity of your threads, and therefore your applications overall performance.

Processors
The Xbox 360 has a 3 core processor capable of running 2 hardware threads each. For simplicity sake, think of this as a system with 6 processors. You can set your threads affinity to 4 of the 6 "processors". Each processor is identified by a number, 0 through 5, and processors 0 and 2 are not available for your use.

Now that we have established some basics about multithreading and the Xbox 360, lets look at the single method that makes all of this possible.

SetProcessorAffinity
The SetProcessorAffinity method of the Thread class is the only method needed to manage the processor affinity of your games while running on the Xbox 360. In fact, this method is only available for Xbox 360 projects.

Never miss an article! Subscribe to my newsletter and I'll keep you updated with the latest content.

 

About Jason

Jason is an experienced entrepreneur & software developer skilled in leadership, mobile development, data synchronization, and SaaS architecture. He earned his Bachelor of Science (B.S.) in Computer Science from Arkansas State University.
View all posts by Jason →

Leave a Reply

Your email address will not be published. Required fields are marked *